Package jaxx.compiler

Class ClassMap<T>

java.lang.Object
java.util.AbstractMap<K,​V>
java.util.HashMap<ClassDescriptor,​T>
jaxx.compiler.ClassMap<T>
Type Parameters:
T - type of the class
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<ClassDescriptor,​T>

public class ClassMap<T>
extends java.util.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
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.util.AbstractMap

    java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>

    Nested classes/interfaces inherited from interface java.util.Map

    java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected static org.apache.commons.logging.Log log
    Logger
  • Constructor Summary

    Constructors
    Constructor Description
    ClassMap()  
  • Method Summary

    Modifier and Type Method Description
    T get​(java.lang.Object key)
    Returns the value associated with the key Class.
    T put​(ClassDescriptor key, T value)
    Associates a value with a class and all of its descendents.

    Methods inherited from class java.util.HashMap

    clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values

    Methods inherited from class java.util.AbstractMap

    equals, hashCode, toString

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Map

    equals, hashCode
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
      Logger
  • Constructor Details

    • ClassMap

      public ClassMap()
  • Method Details

    • get

      public T get​(java.lang.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 java.util.Map<ClassDescriptor,​T>
      Overrides:
      get in class java.util.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 java.util.Map<ClassDescriptor,​T>
      Overrides:
      put in class java.util.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