Skip to content

Commit

Permalink
Add some javadocs, plus more precisely narrow where an exception is c…
Browse files Browse the repository at this point in the history
…aught.
  • Loading branch information
cgruber committed Jun 28, 2013
1 parent ec9c6be commit 525cb97
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/dagger/internal/FailoverLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public final class FailoverLoader implements Loader {
* Obtains a module adapter for {@code module} from the first responding resolver.
*/
@Override public <T> ModuleAdapter<T> getModuleAdapter(Class<? extends T> type, T instance) {
ModuleAdapter<T> result = null;
try {
ModuleAdapter<T> result = GeneratedAdapters.initModuleAdapter(type);
result.module = (instance != null) ? instance : result.newModule();
return result;
result = GeneratedAdapters.initModuleAdapter(type);
} catch (ClassNotFoundException e) {
throw new TypeNotPresentException(type + GeneratedAdapters.MODULE_ADAPTER_SUFFIX, e);
}
result.module = (instance != null) ? instance : result.newModule();
return result;
}

@Override public Binding<?> getAtInjectBinding(String key, String className,
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/java/dagger/internal/loaders/GeneratedAdapters.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,28 @@ public final class GeneratedAdapters {

private GeneratedAdapters() { }

/**
* Attempts to load an adapter named from the provided type plus a constant suffix
* {@link #MODULE_ADAPTER_SUFFIX}, or throws a ClassNotFoundException.
*/
public static <T> ModuleAdapter<T> initModuleAdapter(Class<? extends T> moduleClass)
throws ClassNotFoundException {
return instantiate(moduleClass.getName() + MODULE_ADAPTER_SUFFIX, moduleClass.getClassLoader());
}

/**
* Attempts to load an adapter named from the provided class name plus a constant suffix
* {@link #INJECT_ADAPTER_SUFFIX}, or throws a ClassNotFoundException.
*/
public static Binding<?> initInjectAdapter(String className, ClassLoader classLoader)
throws ClassNotFoundException {
return instantiate(className + INJECT_ADAPTER_SUFFIX, classLoader);
}

/**
* Attempts to load an adapter named from the provided type plus a constant suffix
* {@link #STATIC_INJECTION_SUFFIX}, or throws a ClassNotFoundException.
*/
public static StaticInjection initStaticInjection(Class<?> injectedClass)
throws ClassNotFoundException {
return instantiate(injectedClass.getName() + STATIC_INJECTION_SUFFIX,
Expand Down

0 comments on commit 525cb97

Please sign in to comment.