Class StateEvent

java.lang.Object
org.oddjob.state.StateEvent

public final class StateEvent extends Object
An instance of this class is produced when a job state changes. It is passed to all JobStateListeners.

Author:
Rob Gordon
  • Field Details

  • Constructor Details

  • Method Details

    • atInstant

      public static StateEvent atInstant(Stateful source, State state, StateInstant instant)
      Create a new State Event at the given instant.
      Parameters:
      source - The source of the event.
      state - The state.
      instant - The date time of the event.
      Returns:
      A new State Event.
    • now

      public static StateEvent now(Stateful source, State state)
      Create a new State Event with an instant of now.
      Parameters:
      source - The source of the event.
      state - The state.
      Returns:
      A new State Event.
    • exceptionAtInstant

      public static StateEvent exceptionAtInstant(Stateful source, State exceptionState, StateInstant instant, Throwable exception)
      Create a new State Event at the given instant with the given Exception. The state is expected to have
      invalid @link
      {@link @State#isException
      } true, but this isn't validated.
      Parameters:
      source - The source of the event.
      exceptionState - The state.
      instant - The date time of the event.
      exception -
      Returns:
      A new State Event.
    • exceptionNow

      public static StateEvent exceptionNow(Stateful source, State exceptionState, Throwable exception)
      Create a new State Event with an instant of now and the given Exception. The state is expected to have
      invalid @link
      {@link @State#isException
      } true, but this isn't validated.
      Parameters:
      source - The source of the event.
      exceptionState - The state.
      exception -
      Returns:
      A new State Event.
    • fromDetail

      public static StateEvent fromDetail(Stateful source, StateDetail stateDetail)
      Create a new State Event with the given source and the other details taken from the State Detail.
      Parameters:
      source - The source of the event.
      stateDetail - Provide the other details of the event.
      Returns:
      A new State Event.
    • copy

      public StateEvent.Clone copy()
      Create a mutable copy of the event.
      Returns:
      A mutable copy.
    • getSource

      public Stateful getSource()
    • getState

      public State getState()
      Get the job state.
      Returns:
      The job state.
    • getException

      public Throwable getException()
      Get the exception if applicable, null otherwise.
      Returns:
      The exception of null.
    • getTime

      @Deprecated(since="1.7", forRemoval=true) public Date getTime()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the time of the event. Deprecated - used getInstant().
      Returns:
      The time.
    • getInstant

      public Instant getInstant()
      Get the time of the event as an instant.
      Returns:
      The time.
    • getStateInstant

      public StateInstant getStateInstant()
      Get the time of the event as a State Instant.
      Returns:
      The State Instant.
    • serializable

      public StateDetail serializable()
      Provide something that can be serialised. Note that we do not use writeReplace because there would need to be the corresponding readResolve
      Returns:
      A serializable version of the event without the source.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Override toString.
      Overrides:
      toString in class Object