InputType inputType = component.getFacet(HintsFacet.class).getInputType();
OptionCompleter strategy = null;
if (inputType == InputType.FILE_PICKER && cwd.isDirectory())
{
strategy = new FileOptionCompleter(cwd);
}
else if (inputType == InputType.DIRECTORY_PICKER && cwd.isDirectory())
{
strategy = new FileOptionCompleter(cwd, Filter.DIRECTORY);
}
else if (component instanceof SelectComponent)
{
strategy = new SelectComponentOptionCompleter((SelectComponent<?, Object>) component, converterFactory);
}
else if (Resource.class.isAssignableFrom(component.getValueType()))
{
// fall back to Resource completion.
strategy = new FileOptionCompleter(cwd);
}
// Always try UICompleter first and then fallback to the chosen strategy
strategy = new UICompleterOptionCompleter(strategy, context, component, converterFactory);
return strategy;
}