public class BindingHelper extends java.lang.Object implements Binding
BindingMatch
annotation to make
writing bindings extremely easy.
Methods must have the following and only the following parameters:
ArgumentStack
Annotation
if there is a classifier setAnnotation
[]
if there BindingMatch.provideModifiers()
is trueMethods may throw any exception. Exceptions may be converted using a
ExceptionConverter
registered with the ParametricBuilder
.
Constructor and Description |
---|
BindingHelper()
Create a new instance.
|
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.
|
public java.lang.reflect.Type[] getTypes()
Binding
public int getConsumedCount(ParameterData parameter)
Binding
This method must return -1 for binding behavior types that are not
BindingBehavior.CONSUMES
.
getConsumedCount
in interface Binding
parameter
- information about the parameterpublic BindingBehavior getBehavior(ParameterData parameter)
Binding
ArgumentStack
.getBehavior
in interface Binding
parameter
- information about the parameterpublic java.lang.Object bind(ParameterData parameter, ArgumentStack scoped, boolean onlyConsume) throws ParameterException, CommandException, java.lang.reflect.InvocationTargetException
Binding
ArgumentStack
in order to instantiate an object for the given parameter.bind
in interface Binding
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
public java.util.List<java.lang.String> getSuggestions(ParameterData parameter, java.lang.String prefix)
Binding
getSuggestions
in interface Binding
parameter
- information about the parameterprefix
- what the user has typed so far (may be an empty string)