Package org.dellroad.stuff.vaadin24.util
Class AsyncTaskStatusChangeEvent<R>
java.lang.Object
java.util.EventObject
org.dellroad.stuff.vaadin24.util.AsyncTaskStatusChangeEvent<R>
- Type Parameters:
R
- task result type
- All Implemented Interfaces:
Serializable
Event type emitted by an
AsyncTaskManager
when an AsyncTask
changes status.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Status value indicating that an asynchronous task wascancelTask()
'ed (or canceled itself by throwingInterruptedException
).static final int
Status value indicating that an asynchronous task has completed successfully.static final int
Status value indicating that an asynchronous task failed (i.e., threw an exception).static final int
Status value indicating that a new asynchronous task has started.Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionAsyncTaskStatusChangeEvent
(AsyncTaskManager<R> source, long id, int status, R result, Throwable exception) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the exception thrown by the associated asynchronous task that failed or was canceled.Get the result from the successfully completed associated asynchronous task.Get theAsyncTaskManager
that originated this event.int
long
Get the ID of the associated asynchronous task.Methods inherited from class java.util.EventObject
toString
-
Field Details
-
STARTED
public static final int STARTEDStatus value indicating that a new asynchronous task has started.- See Also:
-
COMPLETED
public static final int COMPLETEDStatus value indicating that an asynchronous task has completed successfully.- See Also:
-
CANCELED
public static final int CANCELEDStatus value indicating that an asynchronous task wascancelTask()
'ed (or canceled itself by throwingInterruptedException
).- See Also:
-
FAILED
public static final int FAILEDStatus value indicating that an asynchronous task failed (i.e., threw an exception).- See Also:
-
-
Constructor Details
-
AsyncTaskStatusChangeEvent
public AsyncTaskStatusChangeEvent(AsyncTaskManager<R> source, long id, int status, R result, Throwable exception) Constructor.- Parameters:
source
- source for this eventid
- task unique IDresult
- task result, or null if notCOMPLETED
exception
- thrown exception, or null if notCANCELED
orFAILED
- Throws:
IllegalArgumentException
- ifsource
is nullIllegalArgumentException
- ifid
is zeroIllegalArgumentException
- ifstatus
is invalidIllegalArgumentException
- ifresult
orexception
is inconsistent withstatus
-
-
Method Details
-
getTaskId
public long getTaskId()Get the ID of the associated asynchronous task.- Returns:
- task ID
-
getStatus
public int getStatus()Get the new status of the associated asynchronous task: one ofSTARTED
,COMPLETED
,CANCELED
, orFAILED
.- Returns:
- status
-
getSource
Get theAsyncTaskManager
that originated this event.- Overrides:
getSource
in classEventObject
- Returns:
- event originator
-
getResult
Get the result from the successfully completed associated asynchronous task.This method returns null except when the status is
COMPLETED
, in which case it returns the result of the task.- Returns:
- task result, or null if task has not completed successfully
-
getException
Get the exception thrown by the associated asynchronous task that failed or was canceled.This method returns null except when the status is
FAILED
orCANCELED
, in which case it returns the exception thrown. In the case ofCANCELED
, this will always be anInterruptedException
.- Returns:
- error thrown, or null if task has not yet finished or completed successfully
-