use of org.apache.karaf.shell.support.completers.UriCompleter in project karaf by apache.
the class ArgumentCompleter method getDefaultCompleter.
@SuppressWarnings({ "unchecked", "rawtypes" })
private Completer getDefaultCompleter(Field field, boolean multi) {
Completer completer = null;
Class<?> type = field.getType();
GenericType genericType = new GenericType(field.getGenericType());
if (Collection.class.isAssignableFrom(genericType.getRawClass()) && multi) {
type = genericType.getActualTypeArgument(0).getRawClass();
}
if (type.isAssignableFrom(URI.class)) {
completer = new UriCompleter();
} else if (type.isAssignableFrom(File.class)) {
completer = new FileCompleter();
} else if (type.isAssignableFrom(Boolean.class) || type.isAssignableFrom(boolean.class)) {
completer = new StringsCompleter(Arrays.asList("false", "true"));
} else if (Enum.class.isAssignableFrom(type)) {
Set<String> values = new HashSet<>();
for (Object o : EnumSet.allOf((Class<Enum>) type)) {
values.add(o.toString());
}
completer = new StringsCompleter(values);
}
return completer;
}
Aggregations