@Test public void testGetSuggestions() throws Exception { Namespace namespace = new Namespace(); assertThat( provider.getSuggestions("", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("small", "medium", "large", "very_large")); assertThat( provider.getSuggestions("s", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("small")); assertThat( provider.getSuggestions("la", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("large")); assertThat( provider.getSuggestions("very", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("very_large")); assertThat( provider.getSuggestions("verylarg", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("very_large")); assertThat( provider.getSuggestions("very_", namespace, ImmutableList.<Annotation>of()), containsInAnyOrder("very_large")); assertThat( provider.getSuggestions("tiny", namespace, ImmutableList.<Annotation>of()), Matchers.<String>empty()); }
@Override public List<String> getSuggestions( String prefix, Namespace namespace, List<? extends Annotation> modifiers) { List<String> suggestions = Lists.newArrayList(); String test = simplify(prefix); for (T entry : enumClass.getEnumConstants()) { String name = simplify(entry.name()); if (name.toLowerCase().startsWith(test.toLowerCase())) { suggestions.add(entry.name().toLowerCase()); } } return suggestions; }
EnumProvider implements Provider<T> { @Override public List<String> getSuggestions( String prefix, Namespace namespace, List<? extends Annotation> modifiers) { List<String> suggestions = Lists.newArrayList(); String test = simplify(prefix); for (T entry : enumClass.getEnumConstants()) { String name = simplify(entry.name()); if (name.toLowerCase().startsWith(test.toLowerCase())) { suggestions.add(entry.name().toLowerCase()); } } return suggestions; } }
EnumProvider implements Provider<T> { @Override public List<String> getSuggestions( String prefix, Namespace namespace, List<? extends Annotation> modifiers) { List<String> suggestions = Lists.newArrayList(); String test = simplify(prefix); for (T entry : enumClass.getEnumConstants()) { String name = simplify(entry.name()); if (name.toLowerCase().startsWith(test.toLowerCase())) { suggestions.add(entry.name().toLowerCase()); } } return suggestions; } EnumProvider(Class<T> enumClass); }
EnumProvider implements Provider<T> { @Override public List<String> getSuggestions( String prefix, Namespace namespace, List<? extends Annotation> modifiers) { List<String> suggestions = Lists.newArrayList(); String test = simplify(prefix); for (T entry : enumClass.getEnumConstants()) { String name = simplify(entry.name()); if (name.toLowerCase().startsWith(test.toLowerCase())) { suggestions.add(entry.name().toLowerCase()); } } return suggestions; } EnumProvider(Class<T> enumClass); @Override String getName(); @Nullable @Override T get(CommandArgs arguments, List<? extends Annotation> modifiers); @Override List<String> getSuggestions(
      String prefix, Namespace namespace, List<? extends Annotation> modifiers); }
EnumProvider implements Provider<T> { @Override public List<String> getSuggestions( String prefix, Namespace namespace, List<? extends Annotation> modifiers) { List<String> suggestions = Lists.newArrayList(); String test = simplify(prefix); for (T entry : enumClass.getEnumConstants()) { String name = simplify(entry.name()); if (name.toLowerCase().startsWith(test.toLowerCase())) { suggestions.add(entry.name().toLowerCase()); } } return suggestions; } EnumProvider(Class<T> enumClass); @Override String getName(); @Nullable @Override T get(CommandArgs arguments, List<? extends Annotation> modifiers); @Override List<String> getSuggestions(
      String prefix, Namespace namespace, List<? extends Annotation> modifiers);  }