Search in sources :

Example 61 with AnnotationValue

use of javax.lang.model.element.AnnotationValue in project auto by google.

the class AnnotationValuesTest method getInts.

@Test
public void getInts() {
    AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "intValues");
    assertThat(AnnotationValues.getInts(value)).containsExactly(1, 2).inOrder();
}
Also used : AnnotationValue(javax.lang.model.element.AnnotationValue) Test(org.junit.Test)

Example 62 with AnnotationValue

use of javax.lang.model.element.AnnotationValue in project auto by google.

the class AnnotationValuesTest method getInt.

@Test
public void getInt() {
    AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "intValue");
    assertThat(AnnotationValues.getInt(value)).isEqualTo(5);
}
Also used : AnnotationValue(javax.lang.model.element.AnnotationValue) Test(org.junit.Test)

Example 63 with AnnotationValue

use of javax.lang.model.element.AnnotationValue in project auto by google.

the class AnnotationValuesTest method getTypeMirror.

@Test
public void getTypeMirror() {
    TypeElement insideClassA = getTypeElement(InsideClassA.class);
    AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "classValue");
    assertThat(AnnotationValues.getTypeMirror(value).asElement()).isEqualTo(insideClassA);
}
Also used : TypeElement(javax.lang.model.element.TypeElement) AnnotationValue(javax.lang.model.element.AnnotationValue) Test(org.junit.Test)

Example 64 with AnnotationValue

use of javax.lang.model.element.AnnotationValue in project auto by google.

the class AnnotationValuesTest method getAnnotationValues.

@Test
public void getAnnotationValues() {
    AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "intValues");
    ImmutableList<AnnotationValue> values = AnnotationValues.getAnnotationValues(value);
    assertThat(values).comparingElementsUsing(Correspondence.transforming(AnnotationValue::getValue, "has value")).containsExactly(1, 2).inOrder();
}
Also used : AnnotationValue(javax.lang.model.element.AnnotationValue) Test(org.junit.Test)

Example 65 with AnnotationValue

use of javax.lang.model.element.AnnotationValue in project auto by google.

the class AnnotationValuesTest method getByte.

@Test
public void getByte() {
    AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "byteValue");
    assertThat(AnnotationValues.getByte(value)).isEqualTo((byte) 7);
}
Also used : AnnotationValue(javax.lang.model.element.AnnotationValue) Test(org.junit.Test)

Aggregations

AnnotationValue (javax.lang.model.element.AnnotationValue)182 AnnotationMirror (javax.lang.model.element.AnnotationMirror)81 TypeElement (javax.lang.model.element.TypeElement)62 ArrayList (java.util.ArrayList)54 ExecutableElement (javax.lang.model.element.ExecutableElement)53 TypeMirror (javax.lang.model.type.TypeMirror)48 List (java.util.List)45 Test (org.junit.Test)30 DeclaredType (javax.lang.model.type.DeclaredType)27 Map (java.util.Map)20 HashSet (java.util.HashSet)19 HashMap (java.util.HashMap)18 VariableElement (javax.lang.model.element.VariableElement)15 Element (javax.lang.model.element.Element)14 ElementUtils.getAnnotationValue (com.oracle.truffle.dsl.processor.java.ElementUtils.getAnnotationValue)10 ElementUtils.fromTypeMirror (com.oracle.truffle.dsl.processor.java.ElementUtils.fromTypeMirror)9 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)8 ElementUtils.resolveAnnotationValue (com.oracle.truffle.dsl.processor.java.ElementUtils.resolveAnnotationValue)7 ElementUtils.unboxAnnotationValue (com.oracle.truffle.dsl.processor.java.ElementUtils.unboxAnnotationValue)7 ArrayCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror)7