Class HandlerList<H>

  • Type Parameters:
    H - Parent class/interface for all handlers

    public final class HandlerList<H>
    extends java.lang.Object
    Manages a list of handlers for objects. Handlers are appended to a list in sequence, and when querying, the last added handler will be used where the query object can be cast to the handlers restriction class.
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.ArrayList<Pair<java.lang.Class<?>,​H>> handlers
      List with registered Handlers.
    • Constructor Summary

      Constructors 
      Constructor Description
      HandlerList()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      H getHandler​(java.lang.Object o)
      Find a matching handler for the given object
      void insertHandler​(java.lang.Class<?> restrictionClass, H handler)
      Insert a handler to the beginning of the stack.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • handlers

        private java.util.ArrayList<Pair<java.lang.Class<?>,​H>> handlers
        List with registered Handlers. The list is kept in backwards order, that is the later entrys take precedence.
    • Constructor Detail

      • HandlerList

        public HandlerList()
    • Method Detail

      • insertHandler

        public void insertHandler​(java.lang.Class<?> restrictionClass,
                                  H handler)
        Insert a handler to the beginning of the stack.
        Parameters:
        restrictionClass - restriction class
        handler - handler
      • getHandler

        public H getHandler​(java.lang.Object o)
        Find a matching handler for the given object
        Parameters:
        o - object to find handler for
        Returns:
        handler for the object. null if no handler was found.