Class EventListeners.Entry<T extends Event>

java.lang.Object
com.prineside.tdi2.events.EventListeners.Entry<T>
Type Parameters:
T - type of an event
All Implemented Interfaces:
Pool.Poolable, KryoSerializable
Enclosing class:
EventListeners<T extends Event>

public static final class EventListeners.Entry<T extends Event> extends Object implements Pool.Poolable, KryoSerializable
Entry inside of an EventListeners, contains some meta data and flags. Returned by add...() methods.
  • Field Details

  • Constructor Details

    • Entry

      public Entry()
  • Method Details

    • write

      public void write(Kryo kryo, Output output)
      Specified by:
      write in interface KryoSerializable
    • read

      public void read(Kryo kryo, Input input)
      Specified by:
      read in interface KryoSerializable
    • getMetaData

      public EventListeners.Entry.EntryMetaData<T> getMetaData()
      Returns:
      entry meta data
    • setName

      public EventListeners.Entry<T> setName(String name)
      Gives listener a name, to make it easier to debug events. It is advised to set a name manually only when the listener does not-so-obvious job or if there are multiple listeners for the same event in a single class. By default, listener's class name will be used as a name.
    • getName

      public String getName()
      Returns:
      previously set name of the entry or, if not set - just a class name of the listener.
    • setDescription

      public EventListeners.Entry<T> setDescription(@Null String description)
      Allows to describe a listener to make it easier to debug. Description should be short but meaningful.
      Parameters:
      description - tells what the listener does
      Returns:
      this, for chaining
    • getDescription

      @Null public String getDescription()
      Returns:
      previously set description or null
    • getPriority

      public int getPriority()
      Returns:
      priority of the entry (set manually or automatically, depending on flags)
    • getListener

      public Listener<T> getListener()
      Returns:
      an actual instance of the listener
    • reset

      public void reset()
      Allows this entry to be re-used, forced to be public by Poolable interface. Called by EventListeners at the moment it frees the entry to the pool, should not be called manually.
      Specified by:
      reset in interface Pool.Poolable
    • remove

      public void remove()
      A convenient way of removing the listener from the group, does exactly the same as EventListeners#remove(listener)
    • isStateAffecting

      public boolean isStateAffecting()
      Check if listener affects game state
      Returns:
      true if listener is state affecting. State affecting listeners are sync checked, serialized and affect the order of other state-affecting listeners (if isAutoPriority())
    • isAutoPriority

      public boolean isAutoPriority()
      Check if listener's priority set automatically by the listener group
      Returns:
      true if listener's priority has been set automatically
    • isPersistent

      public boolean isPersistent()
      Check if listener will survive the EventListeners#reset()
      Returns:
      true if FLAG_PERSISTENT is set, which will make it survive EventListeners#reset()
    • setPersistentToTrue

      public EventListeners.Entry<T> setPersistentToTrue()
      Mark listener as persistent, similar to adding FLAG_PERSISTENT. Can be called at any time.
      Returns:
      this for chaining
    • setPersistent

      public EventListeners.Entry<T> setPersistent(boolean persistent)
      Set listener FLAG_PERSISTENT flag
      Parameters:
      persistent - whether FLAG_PERSISTENT should be set
      Returns:
      this for chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object