1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.convert1.util;
17
18 import java.util.HashMap;
19 import java.util.Iterator;
20
21
22
23
24
25
26 public class ClassMap extends ProxyMap {
27
28 private Inheritor inh;
29
30 public ClassMap() {
31 this(new BasicInheritor());
32 }
33
34 public ClassMap(Inheritor inh) {
35 super(new HashMap());
36 this.inh = inh;
37 }
38
39 public Inheritor getInheritor() {
40 return inh;
41 }
42
43
44
45
46
47 public Object get(Object key) {
48 if(key == null) {
49 return null;
50 }
51 Class clss = null;
52
53 if(key instanceof Class) {
54 clss = (Class) key;
55 } else {
56 clss = key.getClass();
57 }
58
59 Object obj = super.get(clss);
60
61 if(obj == null) {
62
63 inh.setTarget(clss);
64 Iterator itr = inh.iterator();
65 while(itr.hasNext() && obj == null) {
66 obj = super.get(itr.next());
67 }
68 }
69
70 return obj;
71 }
72
73 }