public synchronized void registerIfAbsent(ParameterizedTypeHandlerMap<T> other) {
   if (!modifiable) {
     throw new IllegalStateException("Attempted to modify an unmodifiable map.");
   }
   for (Map.Entry<Type, T> entry : other.userMap.entrySet()) {
     if (!userMap.containsKey(entry.getKey())) {
       register(entry.getKey(), entry.getValue(), false);
     }
   }
   for (Map.Entry<Type, T> entry : other.systemMap.entrySet()) {
     if (!systemMap.containsKey(entry.getKey())) {
       register(entry.getKey(), entry.getValue(), true);
     }
   }
   // Quite important to traverse the typeHierarchyList from stack bottom first since
   // we want to register the handlers in the same order to preserve priority order
   for (int i = other.userTypeHierarchyList.size() - 1; i >= 0; --i) {
     Pair<Class<?>, T> entry = other.userTypeHierarchyList.get(i);
     int index = getIndexOfSpecificHandlerForTypeHierarchy(entry.first, userTypeHierarchyList);
     if (index < 0) {
       registerForTypeHierarchy(entry, false);
     }
   }
   for (int i = other.systemTypeHierarchyList.size() - 1; i >= 0; --i) {
     Pair<Class<?>, T> entry = other.systemTypeHierarchyList.get(i);
     int index = getIndexOfSpecificHandlerForTypeHierarchy(entry.first, systemTypeHierarchyList);
     if (index < 0) {
       registerForTypeHierarchy(entry, true);
     }
   }
 }
 public synchronized void registerIfAbsent(Type typeOfT, T value) {
   if (!modifiable) {
     throw new IllegalStateException("Attempted to modify an unmodifiable map.");
   }
   if (!userMap.containsKey(typeOfT)) {
     register(typeOfT, value, false);
   }
 }
Beispiel #3
0
 private static <T> void registerIfAbsent(
     Class<?> type, ParameterizedTypeHandlerMap<T> adapters, T adapter) {
   if (!adapters.hasSpecificHandlerFor(type)) {
     adapters.register(type, adapter, false);
   }
 }