public abstract class SingleInputPreprocessor<T> extends AbstractPreprocessorPlugin
ConvertService is used so that any single unresolved module that is
convertible with the type of this preprocessor can be satisfied. For example,
if there is a single unresolved S parameter, and a Converter
exists from T to S, then the parameter can be resolved by
this preprocessor.
NB: There is another base class,
AbstractSingleInputPreprocessor, which
alternately can be used to create module preprocessor plugins for filling
single inputs of particular types. The differences between the two are:
AbstractSingleInputPreprocessor is less structured,
with only a protected helper method getSingleInput(Module, Class) to
look up whether a particular module instance has a single input parameter of
the given type; implementations may look up any number of single inputs of
whatever types, but must implement process(Module) directly in
whatever way they see fit. Conversely, this SingleInputPreprocessor
is more structured, with a generic parameter indicating the type of the
single input that will be handled, and a new protected getValue()
method returning the single input value to inject as appropriate.AbstractSingleInputPreprocessor does not
reason about types beyond type assignability, whereas this
SingleInputPreprocessor checks for single inputs of all types
convertible from the requested type. For example, a module requiring a
single Log input would be filled by a SingleTreePreprocessor
plugin extending this SingleInputPreprocessor, when a
TreeToLogConverter plugin is present, because the machinery of this
class would notice that a single Log is required, that a Tree
can be provided, and that the Tree can be converted into the needed
Log.Therefore: it is recommended to use this class when:
Whereas if you need to handle multiple input types, and/or do not necessarily
want type conversion into the destination single input type, it is
recommended to use AbstractSingleInputPreprocessor instead.
| Constructor and Description |
|---|
SingleInputPreprocessor(Class<T> inputType) |
| Modifier and Type | Method and Description |
|---|---|
abstract T |
getValue()
Gets the single input value to populate.
|
void |
process(Module module) |
cancel, getCancelReason, isCanceledcontext, getContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontext, getContext, setContextCopyright © 2009–2024 ImageJ. All rights reserved.