Search in sources :

Example 1 with FileCompleter

use of org.apache.karaf.shell.console.completer.FileCompleter in project karaf by apache.

the class ArgumentCompleter method getDefaultCompleter.

private Completer getDefaultCompleter(Field field) {
    Completer completer = null;
    Class<?> type = field.getType();
    if (type.isAssignableFrom(File.class)) {
        completer = new FileCompleter(null);
    } else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) {
        completer = new StringsCompleter(new String[] { "false", "true" }, false);
    } else if (type.isAssignableFrom(Enum.class)) {
        Set<String> values = new HashSet<>();
        for (Object o : EnumSet.allOf((Class<Enum>) type)) {
            values.add(o.toString());
        }
        completer = new StringsCompleter(values, false);
    } else {
    // TODO any other completers we can add?
    }
    return completer;
}
Also used : FileCompleter(org.apache.karaf.shell.console.completer.FileCompleter) StringsCompleter(org.apache.karaf.shell.console.completer.StringsCompleter) FileCompleter(org.apache.karaf.shell.console.completer.FileCompleter) Completer(org.apache.karaf.shell.console.Completer) StringsCompleter(org.apache.karaf.shell.console.completer.StringsCompleter) NullCompleter(org.apache.karaf.shell.console.completer.NullCompleter) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Completer (org.apache.karaf.shell.console.Completer)1 FileCompleter (org.apache.karaf.shell.console.completer.FileCompleter)1 NullCompleter (org.apache.karaf.shell.console.completer.NullCompleter)1 StringsCompleter (org.apache.karaf.shell.console.completer.StringsCompleter)1