[weld-commits] Weld SVN: r5486 - extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Jan 18 02:23:58 EST 2010


Author: swd847
Date: 2010-01-18 02:23:57 -0500 (Mon, 18 Jan 2010)
New Revision: 5486

Modified:
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java
Log:
Added the ability to remove annotations from Reannitated



Modified: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java	2010-01-16 17:29:12 UTC (rev 5485)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/reannotated/Reannotated.java	2010-01-18 07:23:57 UTC (rev 5486)
@@ -31,7 +31,13 @@
 
       AnnotationSet(Map<Class<? extends Annotation>, Annotation> annotations, Set<Annotation> delegateAnnotations)
       {
-         list.addAll(annotations.values());
+         for (Annotation a : annotations.values())
+         {
+            if (a != null)
+            {
+               list.add(a);
+            }
+         }
          for (Annotation ann : delegateAnnotations)
          {
             if (!annotations.containsKey(ann.annotationType()))
@@ -70,21 +76,14 @@
       if (isAnnotationPresent(annotationType))
       {
          X redefined = visitor.redefine(getAnnotation(annotationType), this);
-         if (redefined == null)
-         {
-            annotations.remove(annotationType);
-         }
-         else
-         {
-            annotations.put(annotationType, redefined);
-         }
+         annotations.put(annotationType, redefined);
       }
    }
 
-   /*
-    * public void undefine(Class<? extends Annotation> annotationType) {
-    * annotations.put(annotationType, null); }
-    */
+   public void undefine(Class<? extends Annotation> annotationType)
+   {
+      annotations.put(annotationType, null);
+   }
 
    public void define(Annotation ann)
    {
@@ -124,9 +123,10 @@
       {
          throw new IllegalArgumentException("annotationType argument must not be null");
       }
-      Annotation ann = annotations.get(annotationType);
-      if (ann != null)
+
+      if (annotations.containsKey(annotationType))
       {
+         Annotation ann = annotations.get(annotationType);
          return annotationType.cast(ann);
       }
       else
@@ -152,7 +152,11 @@
 
    public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
    {
-      return annotations.containsKey(annotationType) || delegate().isAnnotationPresent(annotationType);
+      if (annotations.containsKey(annotationType))
+      {
+         return annotations.get(annotationType) != null;
+      }
+      return delegate().isAnnotationPresent(annotationType);
    }
 
 }



More information about the weld-commits mailing list