Class TaskResultEvent<T>

java.lang.Object
java.util.EventObject
cl.netswitch.lib.server.TaskResultEvent<T>
Type Parameters:
T - the type of the value computed by the task.
All Implemented Interfaces:
Serializable

public final class TaskResultEvent<T> extends EventObject
TaskResultEvent is used to notify that a task has computed a result.
See Also:
  • Constructor Details

    • TaskResultEvent

      public TaskResultEvent(ServerChannel channel, T value, Throwable thrown, RequestEvent request)
      Constructs a new TaskResultEvent instance.
      Parameters:
      channel - the object on which the event occurred.
      value - the value computed by the task (can be null).
      thrown - exception thrown by the task (can be null).
      request - the request that executed the task (can be null).
      Throws:
      NullPointerException - if channel is null.
  • Method Details

    • getServerChannel

      public ServerChannel getServerChannel()
      Returns the server channel of this event.
      Returns:
      the server channel of this event.
    • getValue

      public T getValue() throws Exception
      Returns the value computed by the task. If the task completed by throwing an exception, this method throws that exception.
      Returns:
      the value computed by the task (can be null).
      Throws:
      Exception - the exception thrown by the task.
      See Also:
    • getError

      public Throwable getError()
      Returns the exception thrown by the task. It returns null if the task returned a value and did not throw an exception.
      Returns:
      the exception or null if no exception was thrown.
      See Also:
    • getRequest

      public RequestEvent getRequest()
      Returns the request that executed the server task.
      Returns:
      the request or null if none specified.