public interface Binding
A binding can be used to handle several types at once. For a binding to be
called, it must be registered with a ParametricBuilder
with
ParametricBuilder.addBinding(Binding, java.lang.reflect.Type...)
.
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
bind(ParameterData parameter,
ArgumentStack scoped,
boolean onlyConsume)
Attempt to consume values (if required) from the given
ArgumentStack
in order to instantiate an object for the given parameter. |
BindingBehavior |
getBehavior(ParameterData parameter)
Get how this binding consumes from a
ArgumentStack . |
int |
getConsumedCount(ParameterData parameter)
Get the number of arguments that this binding will consume, if this
information is available.
|
java.util.List<java.lang.String> |
getSuggestions(ParameterData parameter,
java.lang.String prefix)
Get a list of suggestions for the given parameter and user arguments.
|
java.lang.reflect.Type[] |
getTypes()
Get the types that this binding handles.
|
java.lang.reflect.Type[] getTypes()
BindingBehavior getBehavior(ParameterData parameter)
ArgumentStack
.parameter
- information about the parameterint getConsumedCount(ParameterData parameter)
This method must return -1 for binding behavior types that are not
BindingBehavior.CONSUMES
.
parameter
- information about the parameterjava.lang.Object bind(ParameterData parameter, ArgumentStack scoped, boolean onlyConsume) throws ParameterException, CommandException, java.lang.reflect.InvocationTargetException
ArgumentStack
in order to instantiate an object for the given parameter.parameter
- information about the parameterscoped
- the arguments the user has inputonlyConsume
- true to only consume argumentsParameterException
- thrown if the parameter could not be formulatedCommandException
- on a command exceptionjava.lang.reflect.InvocationTargetException
java.util.List<java.lang.String> getSuggestions(ParameterData parameter, java.lang.String prefix)
parameter
- information about the parameterprefix
- what the user has typed so far (may be an empty string)