@Test public void testBaseAutoComplete() { Set<String> properties = ImmutableSet.of( "abc", NodePropertySpecifier.NTP_SERVERS, NodePropertySpecifier.NTP_SOURCE_INTERFACE); assertThat( AutoCompleteUtils.baseAutoComplete(null, properties).stream() .map(s -> s.getText()) .collect(Collectors.toList()), equalTo(ImmutableList.builder().addAll(properties).build())); assertThat( new ArrayList<>(AutoCompleteUtils.baseAutoComplete("ntP", properties)), equalTo( ImmutableList.of( new AutocompleteSuggestion(NodePropertySpecifier.NTP_SERVERS, false), new AutocompleteSuggestion(NodePropertySpecifier.NTP_SOURCE_INTERFACE, false)))); }
@Nonnull public static List<AutocompleteSuggestion> baseAutoComplete( @Nullable String query, Set<String> allProperties) { String finalQuery = firstNonNull(query, "").toLowerCase(); ImmutableList.Builder<AutocompleteSuggestion> suggestions = new ImmutableList.Builder<>(); String queryWithStars = ".*" + (finalQuery.isEmpty() ? "" : finalQuery + ".*"); Pattern queryPattern = safeGetPattern(queryWithStars); if (queryPattern != null) { suggestions.addAll( allProperties.stream() .filter(prop -> queryPattern.matcher(prop.toLowerCase()).matches()) .map(prop -> new AutocompleteSuggestion(prop, false)) .collect(Collectors.toList())); } return suggestions.build(); }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> baseAutoComplete( @Nullable String query, Set<String> allProperties) { String finalQuery = firstNonNull(query, "").toLowerCase(); ImmutableList.Builder<AutocompleteSuggestion> suggestions = new ImmutableList.Builder<>(); String queryWithStars = ".*" + (finalQuery.isEmpty() ? "" : finalQuery + ".*"); Pattern queryPattern = safeGetPattern(queryWithStars); if (queryPattern != null) { suggestions.addAll( allProperties.stream() .filter(prop -> queryPattern.matcher(prop.toLowerCase()).matches()) .map(prop -> new AutocompleteSuggestion(prop, false)) .collect(Collectors.toList())); } return suggestions.build(); } }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> baseAutoComplete( @Nullable String query, Set<String> allProperties) { String finalQuery = firstNonNull(query, "").toLowerCase(); ImmutableList.Builder<AutocompleteSuggestion> suggestions = new ImmutableList.Builder<>(); String queryWithStars = ".*" + (finalQuery.isEmpty() ? "" : finalQuery + ".*"); Pattern queryPattern = safeGetPattern(queryWithStars); if (queryPattern != null) { suggestions.addAll( allProperties.stream() .filter(prop -> queryPattern.matcher(prop.toLowerCase()).matches()) .map(prop -> new AutocompleteSuggestion(prop, false)) .collect(Collectors.toList())); } return suggestions.build(); }  }
AutoCompleteUtils { @Nonnull public static List<AutocompleteSuggestion> baseAutoComplete( @Nullable String query, Set<String> allProperties) { String finalQuery = firstNonNull(query, "").toLowerCase(); ImmutableList.Builder<AutocompleteSuggestion> suggestions = new ImmutableList.Builder<>(); String queryWithStars = ".*" + (finalQuery.isEmpty() ? "" : finalQuery + ".*"); Pattern queryPattern = safeGetPattern(queryWithStars); if (queryPattern != null) { suggestions.addAll( allProperties.stream() .filter(prop -> queryPattern.matcher(prop.toLowerCase()).matches()) .map(prop -> new AutocompleteSuggestion(prop, false)) .collect(Collectors.toList())); } return suggestions.build(); }  @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> baseAutoComplete( @Nullable String query, Set<String> allProperties) { String finalQuery = firstNonNull(query, "").toLowerCase(); ImmutableList.Builder<AutocompleteSuggestion> suggestions = new ImmutableList.Builder<>(); String queryWithStars = ".*" + (finalQuery.isEmpty() ? "" : finalQuery + ".*"); Pattern queryPattern = safeGetPattern(queryWithStars); if (queryPattern != null) { suggestions.addAll( allProperties.stream() .filter(prop -> queryPattern.matcher(prop.toLowerCase()).matches()) .map(prop -> new AutocompleteSuggestion(prop, false)) .collect(Collectors.toList())); } return suggestions.build(); }  @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);  }