Skip to content

Commit

Permalink
Revert code changes from bea7cd1
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacqu committed Jun 24, 2016
1 parent bea7cd1 commit e5eca38
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@
import java.lang.annotation.Annotation;

/**
* .
* Type safe annotation handler base, which will fire the resolve method only if
* an annotation of the given type is present.
*/
public abstract class TypeSafeAnnotationHandler<T extends Annotation> implements AnnotationHandler {

@Override
public final Object resolveValue(Annotation... annotations) {
public final Object resolveValue(Class<?> clazz, Annotation... annotations) throws Exception {
final Class<T> type = getAnnotationType();
for (Annotation annotation : annotations) {
if (type.isInstance(annotation)) {
return resolveValueSafely(type.cast(annotation));
return resolveValueSafely(clazz, type.cast(annotation));
}
}
return null;
}

/**
* Returns the class of the annotation the handler can process.
*
* @return the annotation type
*/
protected abstract Class<T> getAnnotationType();

/**
* Resolves the value with the matched annotation, guaranteed to never be null.
*
* @param clazz the dependency's type
* @param annotation the matched annotation
* @return the resolved value, or null if none applicable
*/
@Nullable
protected abstract Object resolveValueSafely(T annotation);
}
protected abstract Object resolveValueSafely(Class<?> clazz, T annotation) throws Exception;
}

0 comments on commit e5eca38

Please sign in to comment.