|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ArgumentInterpretationStrategy<T>
This interface defines a strategy object used for interpreting and converting
objects into a target type, such as EFile
. It is used by
the
ArgumentInterpreter.interpret(Object, ArgumentInterpretationStrategy)
method.
Every strategy object is created with a configuration that says which
interpretation results that are valid. After calling
interpretList(List)
, ArgumentInterpreter
calls
validateResult(ArgumentInterpretationResult)
to check that the
result is valid.
Implementations must be immutable.
Field Summary | |
---|---|
static int |
ALLOW_NOT_INTERPRETED
If an object cannot be interpreted, don't treat that as an error. |
static int |
ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT
If the argument interpretation results in zero or two or more result objects, treat that as an error. |
Method Summary | |
---|---|
ArgumentInterpretationResult<T> |
interpretList(List<Object> l)
Interpret the list of supplied objects to the target type. |
void |
validateResult(ArgumentInterpretationResult<T> result)
This is called by ArgumentInterpreter to validate that a result
object returned by
ArgumentInterpreter.interpret(Object, ArgumentInterpretationStrategy)
is valid. |
Field Detail |
---|
static final int ALLOW_NOT_INTERPRETED
This constant is used when configuring an argument interpretation strategy object.
static final int ALLOW_ONE_AND_ONLY_ONE_RESULT_OBJECT
If this setting is combined with ALLOW_NOT_INTERPRETED
, the
result object may be either interpreted or not interpreted.
This constant is used when configuring an argument interpretation strategy object.
Method Detail |
---|
ArgumentInterpretationResult<T> interpretList(List<Object> l) throws ArgumentInterpretationException
If an object in the supplied list cannot be interpreted, the
configuration of the strategy object decides what happens. For instance,
the strategy object may be configured to just ignore objects that it
cannot interpret, or it may be configured to throw an
ArgumentInterpretationException
if it encounters an object it
cannot interpret.
l
- The list of objects to interpret. Before
ArgumentInterpreter
passes this list to this strategy object, it
flattens the list (see FlatteningList
)
and gets the produced objects from any Producer
:s
in the list.
ArgumentInterpreter
by calling the
validateResult(ArgumentInterpretationResult)
method with the
returned object. This means that implementations of this method may
choose to not check for the error conditions that
validateResult(ArgumentInterpretationResult)
detects.
ArgumentInterpretationException
- Upon interpretation errors. The
configuration of the strategy object decides exactly which situations
that get treated as errors.void validateResult(ArgumentInterpretationResult<T> result) throws ArgumentInterpretationException
ArgumentInterpreter
to validate that a result
object returned by
ArgumentInterpreter.interpret(Object, ArgumentInterpretationStrategy)
is valid.
The configuration of the strategy object determines which results that are considered valid.
result
- The result object.
ArgumentInterpretationException
- If the result is somehow
invalid.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |