@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { return (T) getAllAnnotationMap().get(annotationClass); }
private Map<Class<?>, Annotation> getAllAnnotationMap(){ if (classToAnnotationMap == null) { classToAnnotationMap = getAllAnnotationMapCalculated(); } return classToAnnotationMap; }
public Annotation[] getAllAnnotations() { if (annotations == null) { annotations = getAllAnnotationsCalculated(); } return annotations; }
private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); fillAnnotationsForParameters(mapResult, method.getParameterAnnotations());
/** * @param result is the map of classes to annotations to fill * @param annotatedMethod the method to get annotations. Does nothing * if the annotated method is null. */ @SuppressWarnings("unused") private void fillAnnotationsForParameters(final Map<Class<?>, Annotation>[] result, final Annotation[][] paramAnnotations) { for (int i = 0; i < paramAnnotations.length; i++) { final Annotation[] annontations = paramAnnotations[i]; Map<Class<?>, Annotation> map = result[i]; if (map == null) { map = new HashMap<Class<?>, Annotation>(); result[i] = map; } addAnnotations(map, annontations); } }
public boolean isAnnotationPresent( final Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; }
private Map<Method, AnnotatedMethod> getMethodMapCalculated(){ final HashMap<Method, AnnotatedMethod> result = new HashMap<Method, AnnotatedMethod>(); for (final Method method : getTheClass().getMethods()) { result.put(method, new AnnotatedMethodImpl(this, method)); } return result; }
private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); fillAnnotationsForParameters(mapResult, method.getParameterAnnotations());
/** * @param result is the map of classes to annotations to fill * @param annotatedMethod the method to get annotations. Does nothing * if the annotated method is null. */ @SuppressWarnings("unused") private void fillAnnotationsForParameters(final Map<Class<?>, Annotation>[] result, final Annotation[][] paramAnnotations) { for (int i = 0; i < paramAnnotations.length; i++) { final Annotation[] annontations = paramAnnotations[i]; Map<Class<?>, Annotation> map = result[i]; if (map == null) { map = new HashMap<Class<?>, Annotation>(); result[i] = map; } addAnnotations(map, annontations); } }
public boolean isAnnotationPresent( final Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; }
private Map<Method, AnnotatedMethod> getMethodMapCalculated(){ final HashMap<Method, AnnotatedMethod> result = new HashMap<Method, AnnotatedMethod>(); for (final Method method : getTheClass().getMethods()) { result.put(method, new AnnotatedMethodImpl(this, method)); } return result; }
private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); // Get the superclass's overriden method annotations if (superClass != null) { fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass( superClass) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get the superinterfaces' overriden method annotations for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ fillAnnotationsForOneMethod(result, AnnotationManager.getAnnotatedClass(c) .getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes())); } // Get its own annotations. They have preference to inherited annotations. for (final Annotation annotation : getMethod().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
final Map<Class<?>, Annotation>[] mapResult = new Map[method.getParameterAnnotations().length]; final Class<?> superClass = getAnnotatedClass().getTheClass().getSuperclass(); if (superClass != null) { final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); for (final Class<?> c : getAnnotatedClass().getTheClass().getInterfaces()){ final AnnotatedMethod aMethod = aClass.getAnnotatedMethod(getMethod().getName(), getMethod().getParameterTypes()); fillAnnotationsForParameters(mapResult, paramAnnotations); fillAnnotationsForParameters(mapResult, method.getParameterAnnotations());
/** * @param result is the map of classes to annotations to fill * @param annotatedMethod the method to get annotations. Does nothing * if the annotated method is null. */ @SuppressWarnings("unused") private void fillAnnotationsForParameters(final Map<Class<?>, Annotation>[] result, final Annotation[][] paramAnnotations) { for (int i = 0; i < paramAnnotations.length; i++) { final Annotation[] annontations = paramAnnotations[i]; Map<Class<?>, Annotation> map = result[i]; if (map == null) { map = new HashMap<Class<?>, Annotation>(); result[i] = map; } addAnnotations(map, annontations); } }
@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { return (T) getAllAnnotationMap().get(annotationClass); }
public boolean isAnnotationPresent( final Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; }
private Map<Method, AnnotatedMethod> getMethodMapCalculated(){ final HashMap<Method, AnnotatedMethod> result = new HashMap<Method, AnnotatedMethod>(); for (final Method method : getTheClass().getMethods()) { result.put(method, new AnnotatedMethodImpl(this, method)); } return result; }
private Map<Class<?>, Annotation> getAllAnnotationMap(){ if (classToAnnotationMap == null) { classToAnnotationMap = getAllAnnotationMapCalculated(); } return classToAnnotationMap; }