Exemple #1
0
 /** Lookup the value for a key in the context inheritance chain. */
 private Object lookup(Key<?> key) {
   for (int i = 0; i < keyValueEntries.length; i++) {
     if (key.equals(keyValueEntries[i][0])) {
       return keyValueEntries[i][1];
     }
   }
   if (parent == null) {
     return null;
   }
   return parent.lookup(key);
 }
Exemple #2
0
 /** Get the value from the specified context for this key. */
 @SuppressWarnings("unchecked")
 public T get(Context context) {
   T value = (T) context.lookup(this);
   return value == null ? defaultValue : value;
 }