org.schmant.arg
Class AbstractOneToOneArgumentInterpretationStrategy<T>
java.lang.Object
org.schmant.arg.AbstractArgumentInterpretationStrategy<T>
org.schmant.arg.AbstractOneToOneArgumentInterpretationStrategy<T>
- All Implemented Interfaces:
- ArgumentInterpretationStrategy<T>
- Direct Known Subclasses:
- AbstractReadableFileArgumentInterpretationStrategy, InterpretAsDirectoryStrategy, InterpretAsEFileStrategy, InterpretAsEntityHolderStrategy, InterpretAsEntityStrategy, InterpretAsFileDirectoryStrategy, InterpretAsFileStrategy, InterpretAsFutureEntityStrategy, InterpretAsNewWritableFileStrategy, InterpretAsRandomlyAccessibleFileStrategy, InterpretAsReadOnlyDirectoryStrategy, InterpretAsReadOnlyEntityStrategy, InterpretAsUrlStrategy, InterpretAsWritableFileStrategy, InterpretAsXmlSourceStrategy
public abstract class AbstractOneToOneArgumentInterpretationStrategy<T>
- extends AbstractArgumentInterpretationStrategy<T>
This class may be inherited by ArgumentInterpretationStrategy
implementations that have a one-to-one relation between interpreted objects.
(One object is always interpreted into one result object.)
- Since:
- 1.0
- Author:
- Karl Gustafsson
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractOneToOneArgumentInterpretationStrategy
protected AbstractOneToOneArgumentInterpretationStrategy(int... configuration)
interpretObject
protected abstract T interpretObject(Object o,
List<String> trace)
- Subclasses implement this to interpret the supplied object.
- Parameters:
o
- The object to interpret.trace
- The interpretation trace list. The list should be
populated by this method.
- Returns:
- The interpreted object or
null
if it could not be
interpreted.
interpretList
public final ArgumentInterpretationResult<T> interpretList(List<Object> l)
throws ArgumentInterpretationException
- Description copied from interface:
ArgumentInterpretationStrategy
- Interpret the list of supplied objects to the target type.
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.
- Parameters:
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.
- Returns:
- A result object. This object is always checked by
ArgumentInterpreter
by calling the
ArgumentInterpretationStrategy.validateResult(ArgumentInterpretationResult)
method with the
returned object. This means that implementations of this method may
choose to not check for the error conditions that
ArgumentInterpretationStrategy.validateResult(ArgumentInterpretationResult)
detects.
- Throws:
ArgumentInterpretationException
- Upon interpretation errors. The
configuration of the strategy object decides exactly which situations
that get treated as errors.