Class InheritableValueMap
- java.lang.Object
-
- org.onemind.commons.java.datastructure.InheritableValueMap
-
public class InheritableValueMap extends java.lang.Object
Associate a class and an value object and resolve the mapping through the class hierachy. For example, if a value object A is assosiated with Number class that means it is associated with the Number class and all the subclasses of object class. However, if a mapping exists for Integer, the InheritableValueMap will return the value object associated for the Integer. The stopClass controls when the InheritableValueMap stop resolving mapping and return null (when c==stopClass.getSuperClass()). The stopClass also control the hierachy of object that can be added the the map - meaning stopClass.isAssignableFrom(c) must evaluate to true when c is added as mapping key.- Version:
- $Id: InheritableValueMap.java,v 1.3 2005/02/17 19:57:31 thlee Exp $ $Name: $
- Author:
- TiongHiang Lee (thlee@onemindsoft.org)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
_map
the mapping *private java.lang.Class
_stopClass
the stop class *
-
Constructor Summary
Constructors Constructor Description InheritableValueMap()
Use Object.class as stop classInheritableValueMap(java.lang.Class stopClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set
keySet()
Return the key classesvoid
put(java.lang.Class c, java.lang.Object o)
Add the mapping between the class c and the object o.java.lang.Object
resolve(java.lang.Class c)
Resolve the object associated with class cjava.util.Collection
resolveAll(java.lang.Class c)
Resolve all the mapping that could have apply to c in class c's inheritance hierachy
-
-
-
Method Detail
-
put
public void put(java.lang.Class c, java.lang.Object o)
Add the mapping between the class c and the object o. The object o must be the stopClass or a subclass of the stopClass- Parameters:
c
- the classo
- the object
-
resolve
public java.lang.Object resolve(java.lang.Class c)
Resolve the object associated with class c- Parameters:
c
- the class- Returns:
- the object associated with class c, or null
-
keySet
public final java.util.Set keySet()
Return the key classes- Returns:
- the classes
-
resolveAll
public java.util.Collection resolveAll(java.lang.Class c)
Resolve all the mapping that could have apply to c in class c's inheritance hierachy- Parameters:
c
- the class- Returns:
- the Collection contains all the mappings
-
-