List of usage examples for java.lang.reflect AnnotatedElement getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:nl.jeslee.jersey.server.spring.AutowiredInjectResolver.java
private DependencyDescriptor createSpringDependencyDescriptor(final Injectee injectee) { AnnotatedElement annotatedElement = injectee.getParent(); if (annotatedElement.getClass().isAssignableFrom(Field.class)) { return new DependencyDescriptor((Field) annotatedElement, !injectee.isOptional()); } else {/*from w w w . ja va 2 s. c o m*/ return new DependencyDescriptor( new MethodParameter((Constructor) annotatedElement, injectee.getPosition()), !injectee.isOptional()); } }
From source file:org.glassfish.jersey.server.spring.AutowiredInjectResolver.java
private DependencyDescriptor createSpringDependencyDescriptor(final Injectee injectee) { AnnotatedElement annotatedElement = injectee.getParent(); if (annotatedElement.getClass().isAssignableFrom(Field.class)) { return new DependencyDescriptor((Field) annotatedElement, !injectee.isOptional()); } else if (annotatedElement.getClass().isAssignableFrom(Method.class)) { return new DependencyDescriptor(new MethodParameter((Method) annotatedElement, injectee.getPosition()), !injectee.isOptional()); } else//from ww w . ja v a2 s . c o m return new DependencyDescriptor( new MethodParameter((Constructor) annotatedElement, injectee.getPosition()), !injectee.isOptional()); }
From source file:org.seedstack.seed.core.utils.SeedReflectionUtils.java
/** * This methods take as parameter an annotatedElement (Class, Field, Method, * Constructor ) and an annotation class. It returns an annotation instance * that meet the requirement : instance of the class annotationClassToFind. * <p>//ww w. ja v a 2 s . c o m * If annotatedElement is a class the method will reach all super type and * for each of those type, it will reach all implemented interfaces and for * each implemented interfaces it will reach all super interfaces * <p> * If annotatedElement is not a class the method will look for the * annotation class in this element, and in the declaring class and all its ancestors. * <p> * From this list, the method will reach for the annotation class in all * annotation hierarchy. * * @param <T> the annotation type to retrieve * @param annotatedElement The annotated element from where to start. * @param annotationClassToFind The annotation class to find. * @return ? extends Annotation */ @Magic(type = WHITE) public static <T extends Annotation> T getMethodOrAncestorMetaAnnotatedWith(AnnotatedElement annotatedElement, Class<T> annotationClassToFind) { T result = null; if (Member.class.isAssignableFrom(annotatedElement.getClass())) { Class<?> declaringClass = Member.class.cast(annotatedElement).getDeclaringClass(); result = SeedReflectionUtils.getMetaAnnotationFromAncestors(declaringClass, annotationClassToFind); } if (result == null) { return SeedReflectionUtils.getMetaAnnotationFromAncestors(annotatedElement, annotationClassToFind); } else { return result; } }