Package java.lang.annotation

Examples of java.lang.annotation.Annotation.annotationType()


        }

        if (literalValue.getValue() instanceof Annotation) {
          final Annotation annotation = (Annotation) literalValue.getValue();

          final Class<? extends Annotation> aClass = annotation.annotationType();
          final String fieldName = PrivateAccessUtil.condensify(aClass.getPackage().getName()) +
              aClass.getSimpleName() + "_" + String.valueOf(literalValue.getValue().hashCode()).replaceFirst("\\-", "_");

          classStructureBuilder.privateField(fieldName, annotation.annotationType())
              .modifiers(Modifier.Final).initializesWith(AnnotationEncoder.encode(annotation))
View Full Code Here


          final Class<? extends Annotation> aClass = annotation.annotationType();
          final String fieldName = PrivateAccessUtil.condensify(aClass.getPackage().getName()) +
              aClass.getSimpleName() + "_" + String.valueOf(literalValue.getValue().hashCode()).replaceFirst("\\-", "_");

          classStructureBuilder.privateField(fieldName, annotation.annotationType())
              .modifiers(Modifier.Final).initializesWith(AnnotationEncoder.encode(annotation))
              .finish();

          return Refs.get(fieldName);
        }
View Full Code Here

         for (Object o : objects)
         {
            if (o instanceof Annotation)
            {
               Annotation a = (Annotation) o;
               if (name.equals(a.annotationType().getName()))
                  return o;
            }
            else if (name.equals(o.getClass().getName()))
               return o;
         }
View Full Code Here

         {
            Object o = item.getValue();
            if (o instanceof Annotation)
            {
               Annotation a = (Annotation) o;
               if (name.equals(a.annotationType().getName()))
                  return item;
            }
            else if (name.equals(item.getName()))
               return item;
         }
View Full Code Here

  
   public void testSimple() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.Simple";
      Annotation annotation = (Annotation)AnnotationCreator.createAnnotation(expr, Simple.class);
      assertEquals(Simple.class, annotation.annotationType());
   }
  
   public void testSimpleValue() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.SimpleValue(\"Test\")";
View Full Code Here

  
   public void testSimpleValue() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.SimpleValue(\"Test\")";
      Annotation annotation  = (Annotation)AnnotationCreator.createAnnotation(expr, SimpleValue.class);
      assertEquals(SimpleValue.class, annotation.annotationType());
      assertEquals("Test", ((SimpleValue)annotation).value());
   }
  
   public void testSimpleValueWithPropertyReplacement() throws Exception
   {
View Full Code Here

   public void testSimpleValueWithPropertyReplacement() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.SimpleValue(\"${value1}\")";
      System.setProperty("value1", "Test");
      Annotation annotation  = (Annotation)AnnotationCreator.createAnnotation(expr, SimpleValue.class, true);
      assertEquals(SimpleValue.class, annotation.annotationType());
      assertEquals("Test", ((SimpleValue)annotation).value());
   }
  
   public void testSimpleValueWithPropertyReplacementFromProperties() throws Exception
   {
View Full Code Here

   public void testSimpleValueWithPropertyReplacementFromProperties() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.SimpleValue(\"${value1}\")";
      System.setProperty("value1", "Test");
      Annotation annotation  = (Annotation)AnnotationCreator.createAnnotation(expr, SimpleValue.class, System.getProperties());
      assertEquals(SimpleValue.class, annotation.annotationType());
      assertEquals("Test", ((SimpleValue)annotation).value());
   }

   public void testComplex() throws Exception
   {
View Full Code Here

   public void testComplex() throws Exception
   {
      String expr = "@org.jboss.test.annotation.factory.support.Complex(ch='a', string=\"Test123\", flt=9.9, dbl=123456789.99, shrt=1, lng=987654321, integer=123, bool=true, annotation=@org.jboss.test.annotation.factory.support.SimpleValue(\"Yes\"), array={\"Test\", \"123\"}, clazz=java.lang.Long.class, enumVal=org.jboss.test.annotation.factory.support.MyEnum.TWO, primitiveArray={1,2,3})";
      Annotation annotation  = (Annotation)AnnotationCreator.createAnnotation(expr, Complex.class);
      assertEquals(Complex.class, annotation.annotationType());
      Complex complex = (Complex)annotation;
      assertEquals('a', complex.ch());
      assertEquals("Test123", complex.string());
      assertEquals(9,9, complex.flt());
      assertEquals(123456789.99, complex.dbl());
View Full Code Here

      System.setProperty("clazz", "java.lang.Long.class");
      System.setProperty("enumVal", "org.jboss.test.annotation.factory.support.MyEnum.TWO");
      System.setProperty("primitiveArray", "{1, 2, 3}");
     
      Annotation annotation  = (Annotation)AnnotationCreator.createAnnotation(expr, Complex.class, true);
      assertEquals(Complex.class, annotation.annotationType());
      Complex complex = (Complex)annotation;
      assertEquals('a', complex.ch());
      assertEquals("Test123", complex.string());
      assertEquals(9,9, complex.flt());
      assertEquals(123456789.99, complex.dbl());
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.