Search in sources :

Example 26 with AnnotatedElement

use of java.lang.reflect.AnnotatedElement in project spring-framework by spring-projects.

the class MultipleComposedAnnotationsOnSingleAnnotatedElementTests method findMultipleComposedAnnotationsOnMethod.

@Test
public void findMultipleComposedAnnotationsOnMethod() throws Exception {
    AnnotatedElement element = getClass().getDeclaredMethod("multipleComposedCachesMethod");
    assertFindAllMergedAnnotationsBehavior(element);
}
Also used : AnnotatedElement(java.lang.reflect.AnnotatedElement) Test(org.junit.Test)

Example 27 with AnnotatedElement

use of java.lang.reflect.AnnotatedElement in project spring-framework by spring-projects.

the class MultipleComposedAnnotationsOnSingleAnnotatedElementTests method findComposedPlusLocalAnnotationsOnMethod.

@Test
public void findComposedPlusLocalAnnotationsOnMethod() throws Exception {
    AnnotatedElement element = getClass().getDeclaredMethod("composedPlusLocalCachesMethod");
    assertFindAllMergedAnnotationsBehavior(element);
}
Also used : AnnotatedElement(java.lang.reflect.AnnotatedElement) Test(org.junit.Test)

Example 28 with AnnotatedElement

use of java.lang.reflect.AnnotatedElement in project intellij-community by JetBrains.

the class CollectionChildDescriptionImpl method getAnnotation.

@Override
@Nullable
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
    final JavaMethod method = getGetterMethod();
    if (method != null) {
        final T annotation = method.getAnnotation(annotationClass);
        if (annotation != null)
            return annotation;
    }
    final Type elemType = getType();
    return elemType instanceof AnnotatedElement ? ((AnnotatedElement) elemType).getAnnotation(annotationClass) : super.getAnnotation(annotationClass);
}
Also used : Type(java.lang.reflect.Type) AnnotatedElement(java.lang.reflect.AnnotatedElement) Nullable(org.jetbrains.annotations.Nullable)

Example 29 with AnnotatedElement

use of java.lang.reflect.AnnotatedElement in project intellij-community by JetBrains.

the class FixedChildDescriptionImpl method getAnnotation.

@Override
@Nullable
public <T extends Annotation> T getAnnotation(int index, Class<? extends T> annotationClass) {
    final JavaMethod method = getGetterMethod(index);
    if (method != null) {
        final T annotation = method.getAnnotation(annotationClass);
        if (annotation != null)
            return annotation;
    }
    final Type elemType = getType();
    if (elemType instanceof AnnotatedElement) {
        T annotation = ((AnnotatedElement) elemType).getAnnotation(annotationClass);
        if (annotation != null)
            return annotation;
    }
    return super.getAnnotation(annotationClass);
}
Also used : Type(java.lang.reflect.Type) AnnotatedElement(java.lang.reflect.AnnotatedElement) JavaMethod(com.intellij.util.xml.JavaMethod) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AnnotatedElement (java.lang.reflect.AnnotatedElement)29 Test (org.junit.Test)7 Method (java.lang.reflect.Method)5 HashMap (java.util.HashMap)4 SimpleType (com.mysema.codegen.model.SimpleType)3 Type (com.mysema.codegen.model.Type)3 EntityType (com.querydsl.codegen.EntityType)3 Property (com.querydsl.codegen.Property)3 Annotation (java.lang.annotation.Annotation)3 Type (java.lang.reflect.Type)3 ArrayList (java.util.ArrayList)3 UncaughtException (com.carrotsearch.randomizedtesting.RandomizedRunner.UncaughtException)2 QueryEntity (com.querydsl.core.annotations.QueryEntity)2 Constructor (java.lang.reflect.Constructor)2 Nullable (javax.annotation.Nullable)2 MappingException (org.hibernate.MappingException)2 org.hibernate.mapping (org.hibernate.mapping)2 Nullable (org.jetbrains.annotations.Nullable)2 AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)2 StoppedByUserException (org.junit.runner.notification.StoppedByUserException)2