- All Implemented Interfaces:
AsyncDataController
AsyncDataController implementation which delegates all of its
methods to another AsyncDataController specified at construction
time.
This implementation does not declare any methods other than the ones
AsyncDataController offers but implements all of them by forwarding
to another AsyncDataController implementation specified at
construction time.
This class was designed for two reasons:
-
To allow a safer way of class inheritance, so there can be no unexpected
dependencies on overridden methods. To imitate inheritance subclass
DelegatedAsyncDataController: specify theAsyncDataControlleryou want to "subclass" in the constructor and override the required methods or provide new ones. -
To hide other public methods of an
AsyncDataControllerfrom external code. This way, the external code can only access methods which theAsyncDataControllerinterface provides.
Thread safety
The thread safety properties of this class entirely depend on the wrappedAsyncDataController instance.
Synchronization transparency
If instances of this class are synchronization transparent or if its synchronization control can be observed by external code entirely depends on the wrappedAsyncDataController instance.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AsyncDataControllerTheAsyncDataControllerto which the methods are forwarded. -
Constructor Summary
ConstructorsConstructorDescriptionDelegatedAsyncDataController(AsyncDataController controller) Initializes thewrappedControllerfield with the specified argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidcontrolData(Object controlArg) Notifies theAsyncDataLinkproviding the data, that the data should be provided in a specific way.Returns the current progress of the data providing process.toString()
-
Field Details
-
wrappedController
TheAsyncDataControllerto which the methods are forwarded. This field can never benullbecause the constructor throwsNullPointerExceptionifnullwas specified as theAsyncDataController.
-
-
Constructor Details
-
DelegatedAsyncDataController
Initializes thewrappedControllerfield with the specified argument.- Parameters:
controller- theAsyncDataControllerto which the methods are forwarded. This argument cannot benull.- Throws:
NullPointerException- thrown if the specifiedAsyncDataControllerisnull
-
-
Method Details
-
controlData
Notifies theAsyncDataLinkproviding the data, that the data should be provided in a specific way. This may affect the intermediate incomplete datas only and regardless how and when this method was called it may not affect the final and complete data provided by theAsyncDataLink.How exactly the data providing can be affected is entirely implementation dependent. For example an implementation may allow requests like "I don't need intermediate data, only the final one" or set up some priorities, that some part of the data should be provided as soon as possible and others are less important. Also implementations may choose to completely ignore this method call.
In general the order of the control arguments of multiple
controlDatamethod call is considered to be important.Note however, that this method only hints the
AsyncDataLinkand usually implementations cannot make any hard guarantees that they will honor the request.- Specified by:
controlDatain interfaceAsyncDataController- Parameters:
controlArg- the control arguments defining the way how the data should be provided. Implementations may make various restrictions on what this argument is allowed to be (e.g.: its class). Note that the control argument in general is expected to be safely sharable across multiple threads concurrently and to be a relatively lightweight object. That is, it is highly recommended that control arguments be simple immutable objects only containing a minimal number of hints.
-
getDataState
Returns the current progress of the data providing process. The progress as a minimum must contain a double value between 0.0 and 1.0 which defines the rough progress where 0.0 means "just started" and 1.0 means (almost) completed.This method must be implemented to return as quickly as possible. That is, this method should do little more than accessing a
volatilefield or similar actions.In case actual providing of the data has not yet been started and the implementation knows little or nothing about what kind of data will be provided, it should return a
nullAsyncDataStaterather than a state with an arbitrary chosen class.- Specified by:
getDataStatein interfaceAsyncDataController- Returns:
- the current state of progress of the data providing process. This
method may return
nullif the state is not yet available.
-
toString
-