InputType - the type of the data which is to be convertedResultType - the type of the resulting data after conversionpublic final class AsyncDataConverter<InputType,ResultType> extends Object
TaskExecutorService
which should be used to execute the conversion process.
This class effectively just holds a DataConverter and the
TaskExecutorService.
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.AsyncLinks.convertGradually,
AsyncDataTransformer| Constructor and Description |
|---|
AsyncDataConverter(DataConverter<InputType,ResultType> converter,
TaskExecutorService executor)
Creates a new
AsyncDataConverter with the given conversion
routine and TaskExecutorService. |
| Modifier and Type | Method and Description |
|---|---|
DataConverter<InputType,ResultType> |
getConverter()
Returns the data converter object which will carry out the conversion of
the input data.
|
TaskExecutorService |
getExecutor()
Returns the
TaskExecutorService on which the data conversion is
intended to be executed. |
CompletionStage<ResultType> |
submit(CancellationToken cancelToken,
InputType input)
Submits a task to the wrapped
executor which will
carry out the data conversion routine. |
String |
toString()
Returns the string representation of this
AsyncDataConverter in
no particular format. |
public AsyncDataConverter(DataConverter<InputType,ResultType> converter, TaskExecutorService executor)
AsyncDataConverter with the given conversion
routine and TaskExecutorService.converter - the DataConverter which defines the conversion
of input datas. This argument cannot be null.executor - the TaskExecutorService which is to be used
execute the conversion of the
input data. This argument cannot be null.NullPointerException - thrown if any of the arguments is
nullpublic CompletionStage<ResultType> submit(CancellationToken cancelToken, InputType input)
executor which will
carry out the data conversion 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 converted. This argument will be
passed to the wrapped data converter object.
This argument can only be null if the data converter accepts
null objects.CompletionStage representing the conversion routine.
This method never returns null.NullPointerException - thrown if the specified
CancellationToken is nullpublic DataConverter<InputType,ResultType> getConverter()
null.public TaskExecutorService getExecutor()
TaskExecutorService on which the data conversion is
intended to be executed. This TaskExecutorService is the same as
the one specified at construction time.TaskExecutorService on which the data conversion is
intended to be executed. This method never returns null.public String toString()
AsyncDataConverter in
no particular format. The returned string will contain the string
representation of both the data converter and the
executor.
This method is intended to be used for debugging only.