use of org.apache.karaf.shell.support.completers.StringsCompleter 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(new String[] { "false", "true" }, false);
} 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, false);
}
return completer;
}
use of org.apache.karaf.shell.support.completers.StringsCompleter in project cxf by apache.
the class EndpointCompleterSupport method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> list) {
StringsCompleter delegate = new StringsCompleter();
try {
List<Bus> busses = getBusses();
for (Bus b : busses) {
ServerRegistry reg = b.getExtension(ServerRegistry.class);
List<Server> servers = reg.getServers();
for (Server serv : servers) {
if (acceptsFeature(serv)) {
String qname = serv.getEndpoint().getEndpointInfo().getName().getLocalPart();
delegate.getStrings().add(qname);
}
}
}
} catch (Exception e) {
// Ignore
}
return delegate.complete(session, commandLine, list);
}
Aggregations