jaxx.compiler
Class ClassMap<T>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<ClassDescriptor,T>
          extended by 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. 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
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected static org.apache.commons.logging.Log log
          Logger
 
Constructor Summary
ClassMap()
           
 
Method Summary
 T get(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, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, 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 Detail

log

protected static final org.apache.commons.logging.Log 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


Copyright © 2008-2012 CodeLutin. All Rights Reserved.