/** * Obtains a module adapter for {@code module} from the first responding resolver. */ @SuppressWarnings("unchecked") // cache ensures types match @Override public <T> ModuleAdapter<T> getModuleAdapter(Class<T> type) { return (ModuleAdapter<T>) loadedAdapters.get(type); }
/** * Loads a class from a {@code ClassLoader}-specific cache if it's already there, or * loads it from the given {@code ClassLoader} and caching it for future requests. Failures * to load are also cached using the Void.class type. A null {@code ClassLoader} is assumed * to be the system classloader. */ protected Class<?> loadClass(ClassLoader classLoader, String name) { // A null classloader is the system classloader. classLoader = (classLoader != null) ? classLoader : ClassLoader.getSystemClassLoader(); return caches.get(classLoader).get(name); }
/** * Validates that among {@code annotations} there exists only one annotation which is, itself * qualified by {@code \@Qualifier} */ private static Annotation extractQualifier(Annotation[] annotations, Object subject) { Annotation qualifier = null; for (Annotation a : annotations) { if (!IS_QUALIFIER_ANNOTATION.get(a.annotationType())) { continue; } if (qualifier != null) { throw new IllegalArgumentException("Too many qualifier annotations on " + subject); } qualifier = a; } return qualifier; }