DataType - the type of the data which is to be converted and also
the type of the resulting data after conversionpublic final class AsyncDataTransformer<DataType> extends Object
TaskExecutorService which should be used to
execute the transformation process. This class is a less general version of
AsyncDataConverter and can be used when a series of conversion needed
to be done but keeping the type of the objects to be converted.
This class effectively just holds a DataTransformer and the
TaskExecutorService.
This class was created to use a more fitting name when converting to the same type and also to reduce the number of generic argument.
submit method,
methods of this class are synchronization transparent. This
submit method however needs to submit a task to the
TaskExecutorService and as such is not
synchronization transparent.AsyncDataConverter| Constructor and Description |
|---|
AsyncDataTransformer(DataTransformer<DataType> transformer,
TaskExecutorService executor)
Creates a new
AsyncDataTransformer with the given transformation
routine and TaskExecutorService. |
| Modifier and Type | Method and Description |
|---|---|
TaskExecutorService |
getExecutor()
Returns the
TaskExecutorService on which the data transformation
is intended to be executed. |
DataTransformer<DataType> |
getTransformer()
Returns the data transformer object which will carry out the conversion
of the input data.
|
CompletionStage<DataType> |
submit(CancellationToken cancelToken,
DataType input)
Submits a task to the wrapped
executor which will
carry out the data transformation routine. |
String |
toString()
Returns the string representation of this
AsyncDataTransformer in
no particular format. |
public AsyncDataTransformer(DataTransformer<DataType> transformer, TaskExecutorService executor)
AsyncDataTransformer with the given transformation
routine and TaskExecutorService.transformer - the DataTransformer which defines the
transformation of input datas. This argument cannot be null.executor - the TaskExecutorService which is to be used
execute the transformation of
the input data. This argument cannot be null.NullPointerException - thrown if any of the arguments is
nullpublic CompletionStage<DataType> submit(CancellationToken cancelToken, DataType input)
executor which will
carry out the data transformation routine.cancelToken - the CancellationToken which is to be checked
if the submitted task is to be canceled. This is the
CancellationToken which will be forwarded to the specified
TaskExecutor. This argument cannot be null.input - the data which is to be transformed. This argument will be
passed to the wrapped data transformer.
This argument can only be null if the data transformer accepts
null objects.CompletionStage representing the transformation routine.
This method never returns null.public DataTransformer<DataType> getTransformer()
null.public TaskExecutorService getExecutor()
TaskExecutorService on which the data transformation
is intended to be executed. This TaskExecutorService is the same
as the one specified at construction time.TaskExecutorService on which the data transformation
is intended to be executed. This method never returns null.public String toString()
AsyncDataTransformer in
no particular format. The returned string will contain the string
representation of both the data transformer and
the executor.
This method is intended to be used for debugging only.