Examples of AnnotationElement


Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement

            if(!(node.jjtGetChild(0) instanceof ASTAnnotation)) { // child already set the value

               m_annotationElementValueHoldersByName.put("value",

                     new AnnotationElement("value", value));

            }

        } else {
View Full Code Here

Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement

            nestedAnnotationVisitor.visit((ASTAnnotation)node.jjtGetChild(0), data);

            m_annotationElementValueHoldersByName.put(elementName,

                    new AnnotationElement(elementName,

                            AnnotationManager.instantiateNestedAnnotation(elementMethod.elementType, nestedAnnotationElementValueHoldersByName)));

        } else {

            Object typedValue = node.jjtGetChild(0).jjtAccept(this, elementMethod);

            m_annotationElementValueHoldersByName.put(elementName,

                    new AnnotationElement(elementName, typedValue));

        }

        return null;
View Full Code Here

Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement



  private Object getElementValue(Object o) {

    AnnotationElement element = (AnnotationElement) o;

    return element.resolveValueHolderFrom(AnnotationParserTest.class.getClassLoader());



  }
View Full Code Here

Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement

            // single "value" default
            Object value = node.jjtGetChild(0).jjtAccept(this, data);

            if(!(node.jjtGetChild(0) instanceof ASTAnnotation)) { // child already set the value
               m_annotationElementValueHoldersByName.put("value",
                     new AnnotationElement("value", value));
            }
        } else {
            for (int i = 0; i < nr; i++) {
                node.jjtGetChild(i).jjtAccept(this, data);
            }
View Full Code Here

Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement

                    nestedAnnotationElementValueHoldersByName,
                    elementMethod.elementType
                    );
            nestedAnnotationVisitor.visit((ASTAnnotation)node.jjtGetChild(0), data);
            m_annotationElementValueHoldersByName.put(elementName,
                    new AnnotationElement(elementName,
                            AnnotationManager.instantiateNestedAnnotation(elementMethod.elementType, nestedAnnotationElementValueHoldersByName)));
        } else {
            Object typedValue = node.jjtGetChild(0).jjtAccept(this, elementMethod);
            m_annotationElementValueHoldersByName.put(elementName,
                    new AnnotationElement(elementName, typedValue));
        }
        return null;
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.annotation.AnnotationElement

public class AnnotationParserTest extends TestCase {

  protected static final AnnotationParser s_parser = Helper.getAnnotationParser();

  private Object getElementValue(Object o) {
    AnnotationElement element = (AnnotationElement) o;
    return element.resolveValueHolderFrom(AnnotationParserTest.class.getClassLoader());

  }
View Full Code Here

Examples of org.jboss.forge.parser.java.AnnotationElement

   {
      assertEquals("MockJavaAnnotationType", javaAnnotation.getName());
      assertEquals(1, javaAnnotation.getAnnotationElements().size());

      assertTrue(javaAnnotation.hasAnnotationElement("value"));
      AnnotationElement value = javaAnnotation.getAnnotationElement("value");
      assertTrue(javaAnnotation.hasAnnotationElement(value));
      assertEquals("value", value.getName());
      assertEquals("org.jboss.forge.grammar.java.MockNestedJavaAnnotationType",
               value.getTypeInspector().getQualifiedName());
      Annotation<JavaAnnotation> valueDefaultValueAnnotation = value.getDefaultValue().getAnnotation();
      assertEquals("MockNestedJavaAnnotationType",
               valueDefaultValueAnnotation.getName());
      assertTrue(valueDefaultValueAnnotation.isSingleValue());
      assertEquals("-1", valueDefaultValueAnnotation.getLiteralValue());
   }
View Full Code Here

Examples of org.jboss.forge.parser.java.AnnotationElement

      JavaAnnotation nestedAnnotation = (JavaAnnotation) javaAnnotation.getNestedClasses().get(0);
      assertEquals("MockNestedJavaAnnotationType", nestedAnnotation.getName());
      assertEquals(5, nestedAnnotation.getAnnotationElements().size());

      assertTrue(nestedAnnotation.hasAnnotationElement("value"));
      AnnotationElement value = nestedAnnotation.getAnnotationElement("value");
      assertTrue(nestedAnnotation.hasAnnotationElement(value));
      assertEquals("value", value.getName());
      assertEquals("int", value.getType());
      assertTrue(value.getTypeInspector().isPrimitive());
      assertNull(value.getDefaultValue().getLiteral());

      assertTrue(nestedAnnotation.hasAnnotationElement("charSequenceType"));
      AnnotationElement charSequenceType = nestedAnnotation.getAnnotationElement("charSequenceType");
      assertTrue(nestedAnnotation.hasAnnotationElement(charSequenceType));
      assertEquals("charSequenceType", charSequenceType.getName());
      Type<JavaAnnotation> charSequenceTypeType = charSequenceType.getTypeInspector();
      assertEquals(Class.class.getSimpleName(), charSequenceTypeType.getName());
      assertTrue(charSequenceTypeType.isParameterized());
      assertEquals(1,
               charSequenceTypeType.getTypeArguments().size());
      assertEquals("? extends CharSequence",
               charSequenceTypeType.getTypeArguments().get(0).getName());
      assertTrue(charSequenceTypeType.getTypeArguments().get(0).isWildcard());
      assertEquals("String.class", charSequenceType.getDefaultValue().getLiteral());
      assertEquals(String.class, charSequenceType.getDefaultValue().getSingleClass());

      assertTrue(nestedAnnotation.hasAnnotationElement("metasyntacticVariable"));
      AnnotationElement metasyntacticVariable = nestedAnnotation.getAnnotationElement("metasyntacticVariable");
      assertTrue(nestedAnnotation.hasAnnotationElement(metasyntacticVariable));
      assertEquals("metasyntacticVariable", metasyntacticVariable.getName());
      Type<JavaAnnotation> metasyntacticVariableType = metasyntacticVariable.getTypeInspector();
      assertEquals("org.jboss.forge.test.parser.java.common.MockEnumType", metasyntacticVariableType.getQualifiedName());
      assertFalse(metasyntacticVariableType.isArray());
      assertEquals(1, metasyntacticVariable.getAnnotations().size());
      assertEquals("Deprecated",
               metasyntacticVariable.getAnnotations().get(0).getName());
      assertSame(MockEnumType.FOO, metasyntacticVariable.getDefaultValue().getEnum(MockEnumType.class));

      assertTrue(nestedAnnotation.hasAnnotationElement("numberTypes"));
      AnnotationElement numberTypes = nestedAnnotation.getAnnotationElement("numberTypes");
      assertTrue(nestedAnnotation.hasAnnotationElement(numberTypes));
      assertEquals("numberTypes", numberTypes.getName());
      Type<JavaAnnotation> numberTypesType = numberTypes.getTypeInspector();
      assertEquals(Class.class.getSimpleName() + "[]", numberTypesType.getName());
      assertTrue(numberTypesType.isParameterized());
      assertEquals(1, numberTypesType.getTypeArguments().size());
      assertEquals("? extends Number", numberTypesType.getTypeArguments().get(0).getName());
      assertTrue(numberTypesType.getTypeArguments().get(0).isWildcard());
      assertEquals(0, numberTypes.getDefaultValue().getClassArray().length);
      numberTypes.getDefaultValue().setClassArray(Long.class, Double.class);
      assertArrayEquals(new Class[] { Long.class, Double.class }, numberTypes.getDefaultValue().getClassArray());

      assertTrue(nestedAnnotation.hasAnnotationElement("metasyntacticVariables"));
      AnnotationElement metasyntacticVariables = nestedAnnotation.getAnnotationElement("metasyntacticVariables");
      assertTrue(nestedAnnotation.hasAnnotationElement(metasyntacticVariables));
      assertEquals("metasyntacticVariables", metasyntacticVariables.getName());
      Type<JavaAnnotation> metasyntacticVariablesType = metasyntacticVariables.getTypeInspector();
      assertEquals("org.jboss.forge.test.parser.java.common.MockEnumType", metasyntacticVariablesType.getQualifiedName());
      assertTrue(metasyntacticVariablesType.isArray());
      assertEquals(0, metasyntacticVariables.getDefaultValue().getEnumArray(MockEnumType.class).length);
      metasyntacticVariables.getDefaultValue().setEnumArray(MockEnumType.values());
      assertArrayEquals(MockEnumType.values(), metasyntacticVariables.getDefaultValue().getEnumArray(MockEnumType.class));
   }
View Full Code Here

Examples of org.jboss.forge.parser.java.AnnotationElement

   }

   @Test
   public void testAddAnnotationElement()
   {
      AnnotationElement someElement = javaAnnotation.addAnnotationElement().setName("someElement")
               .setType(String[].class);
      assertTrue(javaAnnotation.hasAnnotationElement(someElement));

      assertEquals("someElement", someElement.getName());
      Type<JavaAnnotation> someElementType = someElement.getTypeInspector();
      assertTrue(someElementType.isArray());
      assertEquals(1, someElementType.getArrayDimensions());
      assertEquals("String[]", someElementType.getName());
   }
View Full Code Here

Examples of org.jboss.forge.parser.java.AnnotationElement

   }

   @Test
   public void testAddAnnotationElementFromDeclaration()
   {
      AnnotationElement someElement = javaAnnotation.addAnnotationElement("String[] someElement();");
      assertTrue(javaAnnotation.hasAnnotationElement(someElement));

      assertEquals("someElement", someElement.getName());
      Type<JavaAnnotation> someElementType = someElement.getTypeInspector();
      assertTrue(someElementType.isArray());
      assertEquals(1, someElementType.getArrayDimensions());
      assertEquals("String[]", someElementType.getName());
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.