MCPcopy Index your code
hub / github.com/antlr/codebuff / get

Method get

output/java8/1.4.17/TypeRegistry.java:78–149  ·  view source on GitHub ↗

{@inheritDoc} @throws AmbiguousMatchException if the registry contains more than value mapped to a maximally-specific type from which key is derived.

(Object key)

Source from the content-addressed store, hash-verified

76 */
77
78 public V get(Object key) {
79 V value = backingStore.get(key);
80 if ( value!=null ) {
81 return value;
82 }
83 Class<?> redirect = cache.get(key);
84 if ( redirect!=null ) {
85 if ( redirect==Void.TYPE ) {
86 return null;
87 }
88 else {
89 return backingStore.get(redirect);
90 }
91 }
92 if ( !(key instanceof Class) ) {
93 return null;
94 }
95 Class<?> keyClass = (Class<?>)key;
96 List<Class<?>> candidates = new ArrayList<Class<?>>();
97 for (Class<?> clazz : backingStore.keySet()) {
98 if ( clazz.isAssignableFrom(keyClass) ) {
99 candidates.add(clazz);
100 }
101 }
102 if ( candidates.isEmpty() ) {
103 cache.put(keyClass, Void.TYPE);
104 return null;
105 }
106 else if ( candidates.size()==1 ) {
107 cache.put(keyClass, candidates.get(0));
108 return backingStore.get(candidates.get(0));
109 }
110 else {
111 for (int i = 0; i<candidates.size()-1; i++) {
112 if ( candidates.get(i)==null ) {
113 continue;
114 }
115 for (int j = i+1; j<candidates.size(); j++) {
116 if ( candidates.get(i).isAssignableFrom(candidates.get(j)) ) {
117 candidates.set(i, null);
118 break;
119 }
120 else if ( candidates.get(j).isAssignableFrom(candidates.get(i)) ) {
121 candidates.set(j, null);
122 }
123 }
124 }
125
126 int j = 0;
127 for (int i = 0; i<candidates.size(); i++) {
128 Class<?> current = candidates.get(i);
129 if ( current==null ) {
130 continue;
131 }
132 if ( i!= j ) {
133 candidates.set(j, current);
134 }
135 j++;

Callers 3

containsKeyMethod · 0.95
putMethod · 0.95
removeMethod · 0.95

Calls 11

getMethod · 0.65
keySetMethod · 0.65
addMethod · 0.65
isEmptyMethod · 0.65
putMethod · 0.65
sizeMethod · 0.65
setMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45
formatMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected