Class ReadExec<R>
- java.lang.Object
-
- com.smartgridready.communicator.async.process.Processor
-
- com.smartgridready.communicator.async.process.ReadExec<R>
-
- Type Parameters:
R- The type of result.
- All Implemented Interfaces:
Executable
public class ReadExec<R> extends Processor implements Executable
Implements an asynchronous read method.
-
-
Constructor Summary
Constructors Constructor Description ReadExec(java.lang.String functionalProfileName, java.lang.String dataPointName, ReadFunction<R> readFunction)Constructs a new instance.ReadExec(java.lang.String functionalProfileName, java.lang.String dataPointName, ReadFunction<R> readFunction, io.reactivex.rxjava3.core.Scheduler scheduler)Constructs a new instance with a custom scheduler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup()Cleans up disposable resources.ExecStatusgetExecStatus()Gets the execution status.java.lang.ThrowablegetExecThrowable()Gets the exception that was thrown.RgetReadValue()Gets the value of the read result.java.time.InstantgetRequestTime()Gets the time stamp of sending the request.java.time.InstantgetResponseTime()Gets the time stamp of receiving the response.AsyncResult<R>getResult()Gets the process result.voidhandleError(java.lang.Throwable t)Handles an error.voidhandleSuccess(AsyncResult<R> result)Handles a finished process.voidprocess(ProcessingType processingType)Executes the processes.voidsetFinishedNotificationReceiver(java.lang.Object notificationReceiver)Sets an object which should receive notifications of status changes.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ReadExec
public ReadExec(java.lang.String functionalProfileName, java.lang.String dataPointName, ReadFunction<R> readFunction)Constructs a new instance.- Parameters:
functionalProfileName- the functional profile namedataPointName- the data point namereadFunction- a reference to the actual method to be called
-
ReadExec
public ReadExec(java.lang.String functionalProfileName, java.lang.String dataPointName, ReadFunction<R> readFunction, io.reactivex.rxjava3.core.Scheduler scheduler)Constructs a new instance with a custom scheduler.- Parameters:
functionalProfileName- the functional profile namedataPointName- the data point namereadFunction- a reference to the actual method to be calledscheduler- a task scheduler
-
-
Method Detail
-
process
public void process(ProcessingType processingType)
Description copied from class:ProcessorExecutes the processes.
-
handleSuccess
public void handleSuccess(AsyncResult<R> result)
Handles a finished process.- Parameters:
result- the process result
-
handleError
public void handleError(java.lang.Throwable t)
Handles an error.- Parameters:
t- the exception that was thrown
-
getResult
public AsyncResult<R> getResult()
Description copied from interface:ExecutableGets the process result.- Specified by:
getResultin interfaceExecutable- Returns:
- an instance of
AsyncResultwith generic type
-
getReadValue
public R getReadValue()
Gets the value of the read result.- Returns:
- a value
-
getExecStatus
public ExecStatus getExecStatus()
Gets the execution status.- Specified by:
getExecStatusin interfaceExecutable- Returns:
- an instance of
ExecStatus
-
getExecThrowable
public java.lang.Throwable getExecThrowable()
Gets the exception that was thrown.- Returns:
- an instance of
Throwable
-
cleanup
public void cleanup()
Cleans up disposable resources.
-
getRequestTime
public java.time.Instant getRequestTime()
Gets the time stamp of sending the request.- Returns:
- an instance of
Instant
-
getResponseTime
public java.time.Instant getResponseTime()
Gets the time stamp of receiving the response.- Returns:
- an instance of
Instant
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setFinishedNotificationReceiver
public void setFinishedNotificationReceiver(java.lang.Object notificationReceiver)
Description copied from interface:ExecutableSets an object which should receive notifications of status changes.- Specified by:
setFinishedNotificationReceiverin interfaceExecutable- Parameters:
notificationReceiver- the receiving object
-
-