Package java.lang.annotation

Examples of java.lang.annotation.Retention


   {
      try
      {
         Class ann = classloader.loadClass(annotation);
         if (!ann.isAnnotation()) return null;
         Retention retention = (Retention) ann.getAnnotation(Retention.class);
         if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;

      }
      catch (ClassNotFoundException ignored)
      {
      }
View Full Code Here


                member.setValue(newValue);
                checkAnnotationMemberValue(newValue);
            }
            if(annType.isResolved()) {
                Class annTypeClass = annType.getTypeClass();
                Retention retAnn = (Retention) annTypeClass.getAnnotation(Retention.class);
                if (retAnn != null && retAnn.value().equals(RetentionPolicy.RUNTIME)) {
                    AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an);
                    if(anyPrevAnnNode != null) {
                        addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an);
                    }
                }
View Full Code Here

    }

    private void configureAnnotation(AnnotationNode node, Annotation annotation) {
        Class type = annotation.annotationType();
        if (type == Retention.class) {
            Retention r = (Retention) annotation;
            RetentionPolicy value = r.value();
            setRetentionPolicy(value, node);
            node.setMember("value", new PropertyExpression(
                    new ClassExpression(ClassHelper.makeWithoutCaching(RetentionPolicy.class, false)),
                    value.toString()));
        } else if (type == Target.class) {
View Full Code Here

        Set<String> types = proc.getSupportedAnnotationTypes();
        Package expectedPkg = I18NMessage.class.getPackage();

        for (final String type : types) {
            Class<?> clazz = Class.forName(type);
            Retention retention = clazz.getAnnotation(Retention.class);
            assertNotNull(retention);

            Documented documented = clazz.getAnnotation(Documented.class);
            assertNotNull(documented);
            assertEquals(RetentionPolicy.SOURCE, retention.value());
            assertTrue(clazz.isAnnotation());
            assertTrue(clazz.isInterface());
            assertEquals(expectedPkg, clazz.getPackage());
        }
    }
View Full Code Here

    public static void checkQualifierImplementations(Set<Annotation> qualifiers)
    {
        for (Annotation qualifier : qualifiers)
        {
            //This is added, because TCK Event tests for this.
            Retention retention = qualifier.annotationType().getAnnotation(Retention.class);
            RetentionPolicy policy = retention.value();
            if(!policy.equals(RetentionPolicy.RUNTIME))
            {
                throw new IllegalArgumentException("Event qualifier RetentionPolicy must be RUNTIME for qualifier : " + qualifier.annotationType().getName());
            }
        }
View Full Code Here

     *
     * @param markerClass the marker annotation class
     */
    public static void validateMarkerAnnotation(Class markerClass)
    {
        Retention policy = (Retention) markerClass.getAnnotation(Retention.class);

        if (policy != null && policy.value() == RetentionPolicy.RUNTIME)
            return;

        throw new IllegalArgumentException(UtilMessages.badMarkerAnnotation(markerClass));
    }
View Full Code Here

                member.setValue(newValue);
                checkAnnotationMemberValue(newValue);
            }
            if(annType.isResolved()) {
              Class annTypeClass = annType.getTypeClass();
              Retention retAnn = (Retention) annTypeClass.getAnnotation(Retention.class);
              if (retAnn != null && retAnn.value().equals(RetentionPolicy.RUNTIME)) {
                AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an);
                if(anyPrevAnnNode != null) {
                  addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an);
                }
              }
View Full Code Here

/*      */   {
/*      */     try
/*      */     {
/* 1026 */       Class ann = this.classloader.loadClass(annotation);
/* 1027 */       if (!ann.isAnnotation()) return null;
/* 1028 */       Retention retention = (Retention)ann.getAnnotation(Retention.class);
/* 1029 */       if ((retention != null) && (retention.value() == RetentionPolicy.RUNTIME)) return ann;
/*      */     }
/*      */     catch (ClassNotFoundException ignored)
/*      */     {
/*      */     }
/*      */
View Full Code Here

   {
      try
      {
         Class ann = classloader.loadClass(annotation);
         if (!ann.isAnnotation()) return null;
         Retention retention = (Retention) ann.getAnnotation(Retention.class);
         if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;

      }
      catch (ClassNotFoundException ignored)
      {
      }
View Full Code Here

     *
     * @param markerClass the marker annotation class
     */
    public static void validateMarkerAnnotation(Class markerClass)
    {
        Retention policy = (Retention) markerClass.getAnnotation(Retention.class);

        if (policy != null && policy.value() == RetentionPolicy.RUNTIME) return;

        throw new IllegalArgumentException(UtilMessages.badMarkerAnnotation(markerClass));
    }
View Full Code Here

TOP

Related Classes of java.lang.annotation.Retention

Copyright © 2018 www.massapicom. 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.