|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onemind.commons.java.datastructure.InheritableValueMap
public class InheritableValueMap
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.
Field Summary | |
---|---|
private java.util.Map |
_map
the mapping * |
private java.lang.Class |
_stopClass
the stop class * |
Constructor Summary | |
---|---|
InheritableValueMap()
Use Object.class as stop class |
|
InheritableValueMap(java.lang.Class stopClass)
|
Method Summary | |
---|---|
java.util.Set |
keySet()
Return the key classes |
void |
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 c |
java.util.Collection |
resolveAll(java.lang.Class c)
Resolve all the mapping that could have apply to c in class c's inheritance hierachy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map _map
private java.lang.Class _stopClass
Constructor Detail |
---|
public InheritableValueMap()
public InheritableValueMap(java.lang.Class stopClass)
stopClass
- the stop classMethod Detail |
---|
public void put(java.lang.Class c, java.lang.Object o)
c
- the classo
- the objectpublic java.lang.Object resolve(java.lang.Class c)
c
- the class
public final java.util.Set keySet()
public java.util.Collection resolveAll(java.lang.Class c)
c
- the class
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |