@SuppressWarnings("unchecked") public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { return (T) getAllAnnotationMap().get(annotationClass); }
/** * @return the cached map of classes to annotations */ private Map<Class<?>, Annotation> getAllAnnotationMap(){ if (classToAnnotationMap == null) { classToAnnotationMap = getAllAnnotationMapCalculated(); } return classToAnnotationMap; }
public Annotation[] getAllAnnotations() { if (annotations == null) { annotations = getAllAnnotationsCalculated(); } return annotations; }
public AnnotatedMethod getAnnotatedMethod(final String name, final Class<?>[] parameterType) { try { return getAnnotatedMethod(getTheClass().getMethod(name, parameterType)); } catch (final SecurityException e) { throw new RuntimeException(e); } catch (final NoSuchMethodException e) { return null; } }
/** * @return the calculated map of classes to annotations */ private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getTheClass().getSuperclass(); // Get the superclass's annotations if (superClass != null) { fillAnnotationsForOneClass(result, superClass); } // Get the superinterfaces' annotations for (final Class<?> c : getTheClass().getInterfaces()) { fillAnnotationsForOneClass(result, c); } // Get its own annotations. They have preferece to inherited annotations. for (final Annotation annotation : getTheClass().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
public AnnotatedMethod getAnnotatedMethod(final Method method) { return getMethodMap().get(method); }
/** * @param result map of classes to annotations * @param baseClass is the superclass or one of the superinterfaces. */ private void fillAnnotationsForOneClass(final HashMap<Class<?>, Annotation> result, final Class<?> baseClass) { addAnnotations(result, AnnotationManager.getAnnotatedClass(baseClass).getAllAnnotations()); }
public AnnotatedMethod[] getAnnotatedMethods() { if (annotatedMethods == null) { annotatedMethods = getAnnotatedMethodsCalculated(); } return annotatedMethods; }
public boolean isAnnotationPresent( final Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; } }
/** * @param theClass to wrap. * @return the annotated class wrapping the specified one. */ public static AnnotatedClass getAnnotatedClass(Class<?> theClass){ AnnotatedClass annotatedClass = classToAnnotatedMap.get(theClass); if (annotatedClass == null){ annotatedClass = new AnnotatedClassImpl(theClass); classToAnnotatedMap.put(theClass, annotatedClass); } return annotatedClass; } }
public AnnotatedMethod getAnnotatedMethod(final String name, final Class<?>[] parameterType) { try { return getAnnotatedMethod(getTheClass().getMethod(name, parameterType)); } catch (final SecurityException e) { throw new RuntimeException(e); } catch (final NoSuchMethodException e) { return null; } }
/** * @return the calculated map of classes to annotations */ private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getTheClass().getSuperclass(); // Get the superclass's annotations if (superClass != null) { fillAnnotationsForOneClass(result, superClass); } // Get the superinterfaces' annotations for (final Class<?> c : getTheClass().getInterfaces()) { fillAnnotationsForOneClass(result, c); } // Get its own annotations. They have preferece to inherited annotations. for (final Annotation annotation : getTheClass().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
public AnnotatedMethod getAnnotatedMethod(final Method method) { return getMethodMap().get(method); }
/** * @param result map of classes to annotations * @param baseClass is the superclass or one of the superinterfaces. */ private void fillAnnotationsForOneClass(final HashMap<Class<?>, Annotation> result, final Class<?> baseClass) { addAnnotations(result, AnnotationManager.getAnnotatedClass(baseClass).getAllAnnotations()); }
public AnnotatedMethod[] getAnnotatedMethods() { if (annotatedMethods == null) { annotatedMethods = getAnnotatedMethodsCalculated(); } return annotatedMethods; }
public boolean isAnnotationPresent( final Class<? extends Annotation> annotationClass) { return getAnnotation(annotationClass) != null; } }
/** * @param theClass to wrap. * @return the annotated class wrapping the specified one. */ public static AnnotatedClass getAnnotatedClass(Class<?> theClass){ AnnotatedClass annotatedClass = classToAnnotatedMap.get(theClass); if (annotatedClass == null){ annotatedClass = new AnnotatedClassImpl(theClass); classToAnnotatedMap.put(theClass, annotatedClass); } return annotatedClass; } }
public AnnotatedMethod getAnnotatedMethod(final String name, final Class<?>[] parameterType) { try { return getAnnotatedMethod(getTheClass().getMethod(name, parameterType)); } catch (final SecurityException e) { throw new RuntimeException(e); } catch (final NoSuchMethodException e) { return null; } }
/** * @return the calculated map of classes to annotations */ private Map<Class<?>, Annotation> getAllAnnotationMapCalculated(){ final HashMap<Class<?>, Annotation> result = new HashMap<Class<?>, Annotation>(); final Class<?> superClass = getTheClass().getSuperclass(); // Get the superclass's annotations if (superClass != null) { fillAnnotationsForOneClass(result, superClass); } // Get the superinterfaces' annotations for (final Class<?> c : getTheClass().getInterfaces()) { fillAnnotationsForOneClass(result, c); } // Get its own annotations. They have preferece to inherited annotations. for (final Annotation annotation : getTheClass().getDeclaredAnnotations()) { result.put(annotation.getClass().getInterfaces()[0], annotation); } return result; }
private AnnotatedMethod[] getAnnotatedMethodsCalculated() { final Collection<AnnotatedMethod> values = getMethodMap().values(); return values.toArray(new AnnotatedMethod[0]); }