Class DeplayedEvent

java.lang.Object
cl.netswitch.lib.server.DeplayedEvent
All Implemented Interfaces:
Comparable<Delayed>, Delayed

public abstract class DeplayedEvent extends Object implements Delayed
Implements the logic common to all delayed events.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DeplayedEvent(long delay)
    Constructs a new DeplayedEvent instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Compares this DeplayedEvent with the specified object for order.
    abstract void
    Dispatched this DeplayedEvent to the target listener.
    final boolean
    equals(Object that)
    Indicates whether some other object is "equal to" this DeplayedEvent.
    final long
    Returns the remaining delay in the given time unit.
    final int
    Returns a hash code value of this DeplayedEvent.
    final long
    Resets the expiration time of this DeplayedEvent for reuse.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DeplayedEvent

      public DeplayedEvent(long delay)
      Constructs a new DeplayedEvent instance.
      Parameters:
      delay - the delay of this DeplayedEvent (milliseconds).
      Throws:
      IllegalArgumentException - if delay is negative.
  • Method Details

    • reset

      public final long reset()
      Resets the expiration time of this DeplayedEvent for reuse.
      Returns:
      the delay between consecutive executions (milliseconds).
    • getDelay

      public final long getDelay(TimeUnit unit)
      Returns the remaining delay in the given time unit.
      Specified by:
      getDelay in interface Delayed
      Parameters:
      unit - the required time unit of the output
      Returns:
      the remaining delay in the given time unit.
      Throws:
      NullPointerException - if unit is null.
    • hashCode

      public final int hashCode()
      Returns a hash code value of this DeplayedEvent.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value of this DeplayedEvent.
    • equals

      public final boolean equals(Object that)
      Indicates whether some other object is "equal to" this DeplayedEvent.
      Overrides:
      equals in class Object
      Parameters:
      that - the object to compare to this object (can be null).
      Returns:
      true if this delayed runnable equals that.
    • compareTo

      public final int compareTo(Delayed that)
      Compares this DeplayedEvent with the specified object for order.
      Specified by:
      compareTo in interface Comparable<Delayed>
      Parameters:
      that - the object to compare to this DeplayedEvent.
      Returns:
      a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than that object.
      Throws:
      NullPointerException - if that is null.
    • dispatch

      public abstract void dispatch() throws Exception
      Dispatched this DeplayedEvent to the target listener.
      Throws:
      Exception - if an error occurs.