Package org.nuiton.jaxx.compiler
Class ClassMap<T>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<ClassDescriptor,T>
-
- org.nuiton.jaxx.compiler.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.ClassMapdiffers 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. Agetoperation 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
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.LoggerlogLogger
-
Constructor Summary
Constructors Constructor Description ClassMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget(Object key)Returns the value associated with the keyClass.Tput(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
-
-
-
-
Method Detail
-
get
public T get(Object key)
Returns the value associated with the keyClass. 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,nullis returned.- Specified by:
getin interfaceMap<ClassDescriptor,T>- Overrides:
getin classHashMap<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:
putin interfaceMap<ClassDescriptor,T>- Overrides:
putin classHashMap<ClassDescriptor,T>- Parameters:
key- the class to mapvalue- the value to map to the class- Returns:
- the old value associated with the class
-
-