Search in sources :

Example 6 with Completion

use of org.springframework.shell.core.Completion in project geode by apache.

the class HintTopicConverter method getAllPossibleValues.

@Override
public boolean getAllPossibleValues(List<Completion> completions, Class<?> targetType, String existingData, String optionContext, MethodTarget target) {
    Helper helper = commandManager.getHelper();
    Set<String> topicNames = helper.getTopicNames();
    for (String topicName : topicNames) {
        if (existingData != null && !existingData.isEmpty()) {
            if (topicName.startsWith(existingData)) {
                // match exact case
                completions.add(new Completion(topicName));
            } else if (topicName.toLowerCase().startsWith(existingData.toLowerCase())) {
                // match
                // case
                // insensitive
                String completionStr = existingData + topicName.substring(existingData.length());
                completions.add(new Completion(completionStr));
            }
        } else {
            completions.add(new Completion(topicName));
        }
    }
    return !completions.isEmpty();
}
Also used : Helper(org.apache.geode.management.internal.cli.help.Helper) Completion(org.springframework.shell.core.Completion)

Aggregations

Completion (org.springframework.shell.core.Completion)6 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)1 List (java.util.List)1 Properties (java.util.Properties)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 StringUtils (org.apache.commons.lang.StringUtils)1 Helper (org.apache.geode.management.internal.cli.help.Helper)1 Gfsh (org.apache.geode.management.internal.cli.shell.Gfsh)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1 Test (org.junit.Test)1 ArrayConverter (org.springframework.shell.converters.ArrayConverter)1 CommandMarker (org.springframework.shell.core.CommandMarker)1 Converter (org.springframework.shell.core.Converter)1 Parser (org.springframework.shell.core.Parser)1 SimpleParser (org.springframework.shell.core.SimpleParser)1 ParseResult (org.springframework.shell.event.ParseResult)1