Class ClassMap<T>

  • Type Parameters:
    T - type of the class
    All Implemented Interfaces:
    Serializable, Cloneable, Map<ClassDescriptor,​T>

    public class ClassMap<T>
    extends HashMap<ClassDescriptor,​T>
    A Map implementation which uses Classes as keys. ClassMap differs from typical maps in that it takes subclasses into account; mapping a class to a value also maps all subclasses of that class to the value. A get operation will return the value associated with the class itself, or failing that, with its nearest ancestor for which there exists a mapping.
    See Also:
    Serialized Form
    • Field Detail

      • log

        protected static final org.apache.logging.log4j.Logger log
        Logger
    • Constructor Detail

      • ClassMap

        public ClassMap()
    • Method Detail

      • get

        public T get​(Object key)
        Returns the value associated with the key Class. If the class itself does not have a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is located. If none of the class' ancestors have a mapping, null is returned.
        Specified by:
        get in interface Map<ClassDescriptor,​T>
        Overrides:
        get in class HashMap<ClassDescriptor,​T>
        Parameters:
        key - the class to check
        Returns:
        the mapping for the class
      • put

        public T put​(ClassDescriptor key,
                     T value)
        Associates a value with a class and all of its descendents.
        Specified by:
        put in interface Map<ClassDescriptor,​T>
        Overrides:
        put in class HashMap<ClassDescriptor,​T>
        Parameters:
        key - the class to map
        value - the value to map to the class
        Returns:
        the old value associated with the class