コード例 #1
0
 /** Performs the search on the artists list. */
 public void onArtistSearch() {
   if ((artistSearch == null) || (artistSearch.trim().isEmpty())) {
     filteredArtists = null;
   } else {
     final Locale locale = languageBean.getLocale();
     final String query = artistSearch.toUpperCase();
     filteredArtists =
         support
             .getArtists()
             .parallelStream()
             .filter(
                 artist -> {
                   switch (selectedArtistSearchOption) {
                     case NAME:
                       return artist.getFullName().toUpperCase().contains(query);
                     case ARTIST_GROUP:
                       return ((artist.getArtistGroup() != null)
                           && (artist.getArtistGroup().toUpperCase().contains(query)));
                     case ARTIST_CATEGORY:
                       return (artist.getArtistCategory() != null)
                           && (artist.getArtistCategory().toUpperCase().contains(query));
                     case COUNTRY:
                       return (artist.getCountryName(locale) != null)
                           ? artist.getCountryName(locale).toUpperCase().contains(query)
                           : Boolean.FALSE;
                     default:
                       throw new IllegalArgumentException(
                           "SearchOption: "
                               + selectedArtistSearchOption.name()
                               + " not supported");
                   }
                 })
             .collect(Collectors.toList());
   }
 }
コード例 #2
0
 /** Performs the search on the venue list. */
 public void onVenueSearch() {
   if ((venueSearch == null) || (venueSearch.trim().isEmpty())) {
     filteredVenues = null;
   } else {
     final String query = venueSearch.toUpperCase();
     filteredVenues =
         support
             .getVenues()
             .parallelStream()
             .filter(
                 venue -> {
                   switch (selectedVenueSearchOption) {
                     case NAME:
                       return venue.getName().toUpperCase().contains(query);
                     case ADDRESS:
                       return venue.getAddress().toUpperCase().contains(query);
                     default:
                       throw new IllegalArgumentException(
                           "SearchOption: "
                               + selectedArtistSearchOption.name()
                               + " not supported");
                   }
                 })
             .collect(Collectors.toList());
   }
 }