@Test public void testStringAutocomplete() { Set<String> strings = ImmutableSet.of("abcd", "degf"); assertThat(getSuggestionsTextSet(stringAutoComplete("d", strings)), equalTo(strings)); assertThat( getSuggestionsTextSet(stringAutoComplete("b", strings)), equalTo(ImmutableSet.of("abcd"))); assertThat( getSuggestionsTextSet(stringAutoComplete("aBCd", strings)), equalTo(ImmutableSet.of("abcd"))); }
@Nonnull public static List<AutocompleteSuggestion> stringAutoComplete( @Nullable String query, Set<String> strings) { String testQuery = query == null ? "" : query.toLowerCase(); return strings.stream() .filter(s -> s.toLowerCase().contains(testQuery)) .map(s -> new AutocompleteSuggestion(s, false)) .collect(ImmutableList.toImmutableList()); }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> stringAutoComplete( @Nullable String query, Set<String> strings) { String testQuery = query == null ? "" : query.toLowerCase(); return strings.stream() .filter(s -> s.toLowerCase().contains(testQuery)) .map(s -> new AutocompleteSuggestion(s, false)) .collect(ImmutableList.toImmutableList()); } }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> stringAutoComplete( @Nullable String query, Set<String> strings) { String testQuery = query == null ? "" : query.toLowerCase(); return strings.stream() .filter(s -> s.toLowerCase().contains(testQuery)) .map(s -> new AutocompleteSuggestion(s, false)) .collect(ImmutableList.toImmutableList()); }  }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> stringAutoComplete( @Nullable String query, Set<String> strings) { String testQuery = query == null ? "" : query.toLowerCase(); return strings.stream() .filter(s -> s.toLowerCase().contains(testQuery)) .map(s -> new AutocompleteSuggestion(s, false)) .collect(ImmutableList.toImmutableList()); }  @Nonnull static List<AutocompleteSuggestion> autoComplete(
      Variable.Type completionType, String query, int maxSuggestions); @Nonnull static List<AutocompleteSuggestion> autoComplete(
      @Nullable String network,
      @Nullable String snapshot,
      Variable.Type completionType,
      String query,
      int maxSuggestions,
      @Nullable CompletionMetadata completionMetadata,
      @Nullable NodeRolesData nodeRolesData,
      @Nullable ReferenceLibrary referenceLibrary); @Nonnull static List<AutocompleteSuggestion> autoComplete(
      @Nullable String network,
      @Nullable String snapshot,
      Variable.Type completionType,
      String query,
      int maxSuggestions,
      @Nullable CompletionMetadata completionMetadata,
      @Nullable NodeRolesData nodeRolesData,
      @Nullable ReferenceLibrary referenceLibrary,
      boolean fuzzyMatching); @Nonnull static List<AutocompleteSuggestion> baseAutoComplete(
      @Nullable String query, Set<String> allProperties); @Nonnull static List<AutocompleteSuggestion> stringAutoComplete(
      @Nullable String query, Set<String> strings); @Nonnull static List<AutocompleteSuggestion> stringAutoComplete(
      @Nullable String query, Map<String, Optional<String>> stringsWithDescriptions); @Nonnull static ImmutableList<AutocompleteSuggestion> ipStringAutoComplete(
      @Nullable String query, Map<Ip, IpCompletionMetadata> ips); }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> stringAutoComplete( @Nullable String query, Set<String> strings) { String testQuery = query == null ? "" : query.toLowerCase(); return strings.stream() .filter(s -> s.toLowerCase().contains(testQuery)) .map(s -> new AutocompleteSuggestion(s, false)) .collect(ImmutableList.toImmutableList()); }  @Nonnull static List<AutocompleteSuggestion> autoComplete(
      Variable.Type completionType, String query, int maxSuggestions); @Nonnull static List<AutocompleteSuggestion> autoComplete(
      @Nullable String network,
      @Nullable String snapshot,
      Variable.Type completionType,
      String query,
      int maxSuggestions,
      @Nullable CompletionMetadata completionMetadata,
      @Nullable NodeRolesData nodeRolesData,
      @Nullable ReferenceLibrary referenceLibrary); @Nonnull static List<AutocompleteSuggestion> autoComplete(
      @Nullable String network,
      @Nullable String snapshot,
      Variable.Type completionType,
      String query,
      int maxSuggestions,
      @Nullable CompletionMetadata completionMetadata,
      @Nullable NodeRolesData nodeRolesData,
      @Nullable ReferenceLibrary referenceLibrary,
      boolean fuzzyMatching); @Nonnull static List<AutocompleteSuggestion> baseAutoComplete(
      @Nullable String query, Set<String> allProperties); @Nonnull static List<AutocompleteSuggestion> stringAutoComplete(
      @Nullable String query, Set<String> strings); @Nonnull static List<AutocompleteSuggestion> stringAutoComplete(
      @Nullable String query, Map<String, Optional<String>> stringsWithDescriptions); @Nonnull static ImmutableList<AutocompleteSuggestion> ipStringAutoComplete(
      @Nullable String query, Map<Ip, IpCompletionMetadata> ips);  }