commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1083849 - in /commons/proper/lang/trunk: pom.xml src/main/java/org/apache/commons/lang3/AnnotationUtils.java src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
Date Mon, 21 Mar 2011 15:58:07 GMT
Author: mbenson
Date: Mon Mar 21 15:58:07 2011
New Revision: 1083849

URL: http://svn.apache.org/viewvc?rev=1083849&view=rev
Log:
retract @Nonbinding support; doesn't seem proper default behavior

Modified:
    commons/proper/lang/trunk/pom.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java

Modified: commons/proper/lang/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/pom.xml?rev=1083849&r1=1083848&r2=1083849&view=diff
==============================================================================
--- commons/proper/lang/trunk/pom.xml (original)
+++ commons/proper/lang/trunk/pom.xml Mon Mar 21 15:58:07 2011
@@ -429,12 +429,6 @@
       <scope>test</scope>
     </dependency>
 
-    <dependency>
-      <groupId>javax.enterprise</groupId>
-      <artifactId>cdi-api</artifactId>
-      <version>1.0-SP1</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <properties>

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java?rev=1083849&r1=1083848&r2=1083849&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
Mon Mar 21 15:58:07 2011
@@ -98,27 +98,6 @@ public class AnnotationUtils {
     };
 
     /**
-     * Statically cached class instance for the CDI Nonbinding annotation.
-     */
-    private static final Class<? extends Annotation> NONBINDING_ANNOTATION_TYPE;
-    static {
-        Class<?> nonbindingAnnotationType = null;
-        try {
-            nonbindingAnnotationType = ClassUtils.getClass("javax.enterprise.util.Nonbinding");
-        } catch (ClassNotFoundException e) {
-        }
-        if (nonbindingAnnotationType != null
-                && Annotation.class.isAssignableFrom(nonbindingAnnotationType)) {
-            //just checked:
-            @SuppressWarnings("unchecked")
-            Class<? extends Annotation> stronglyTyped = (Class<? extends Annotation>)
nonbindingAnnotationType;
-            NONBINDING_ANNOTATION_TYPE = stronglyTyped;
-        } else {
-            NONBINDING_ANNOTATION_TYPE = null;
-        }
-    }
-
-    /**
      * <p>{@code AnnotationUtils} instances should NOT be constructed in
      * standard programming. Instead, the class should be used statically.</p>
      *
@@ -131,11 +110,7 @@ public class AnnotationUtils {
     //-----------------------------------------------------------------------
     /**
      * <p>Checks if two annotations are equal using the criteria for equality
-     * presented in the {@link Annotation#equals(Object)} API docs. Additionally
-     * if the <code>javax.enterprise.util.Nonbinding</code> annotation is found
-     * on the classpath, its implications will be respected:
-     * <code>Nonbinding</code> members will contribute nothing to the equality
-     * calculation.</p>
+     * presented in the {@link Annotation#equals(Object)} API docs.</p>
      *
      * @param a1 the first Annotation to compare, {@code null} returns
      * {@code false} unless both are {@code null}
@@ -161,8 +136,7 @@ public class AnnotationUtils {
         try {
             for (Method m : type.getDeclaredMethods()) {
                 if (m.getParameterTypes().length == 0
-                        && isValidAnnotationMemberType(m.getReturnType())
-                        && !isNonbindingMember(m)) {
+                        && isValidAnnotationMemberType(m.getReturnType())) {
                     Object v1 = m.invoke(a1);
                     Object v2 = m.invoke(a2);
                     if (!memberEquals(m.getReturnType(), v1, v2)) {
@@ -393,15 +367,4 @@ public class AnnotationUtils {
         }
         return Arrays.hashCode((Object[]) o);
     }
-
-    /**
-     * Helper method to look for the CDI {@code Nonbinding} annotation on an
-     * {@link Annotation} member.
-     * @param accessor the accessor method to check
-     * @return whether the {@code Nonbinding} annotation was found
-     */
-    private static boolean isNonbindingMember(Method accessor) {
-        return NONBINDING_ANNOTATION_TYPE != null
-                && accessor.isAnnotationPresent(NONBINDING_ANNOTATION_TYPE);
-    }
 }

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java?rev=1083849&r1=1083848&r2=1083849&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
Mon Mar 21 15:58:07 2011
@@ -37,8 +37,6 @@ import java.lang.reflect.Proxy;
 import java.util.Collection;
 import java.util.Map;
 
-import javax.enterprise.util.Nonbinding;
-
 import org.junit.Before;
 import org.junit.Test;
 
@@ -120,7 +118,6 @@ public class AnnotationUtilsTest {
             type = Object.class,
             types = { Object.class }
     )
-    @Blah(foo = 6, bar = "x")
     public Object dummy1;
 
     @TestAnnotation(
@@ -197,7 +194,6 @@ public class AnnotationUtilsTest {
             type = Object.class,
             types = { Object.class }
     )
-    @Blah(foo = 6, bar = "y")
     public Object dummy2;
 
     @TestAnnotation(
@@ -299,7 +295,6 @@ public class AnnotationUtilsTest {
             type = Object.class,
             types = { Object.class }
     )
-    @Blah(foo = 7, bar = "x")
     public Object dummy3;
 
     @NestAnnotation(
@@ -386,15 +381,6 @@ public class AnnotationUtilsTest {
         MOE, LARRY, CURLY, JOE, SHEMP;
     }
 
-    @Retention(RUNTIME)
-    @Target(FIELD)
-    public @interface Blah {
-        int foo();
-
-        @Nonbinding
-        String bar();
-    }
-
     private Field field1;
     private Field field2;
     private Field field3;
@@ -518,12 +504,4 @@ public class AnnotationUtilsTest {
         assertTrue(toString.contains(", "));
     }
 
-    @Test
-    public void testNonbinding() throws Exception {
-        Blah blah1 = field1.getAnnotation(Blah.class);
-        Blah blah2 = field2.getAnnotation(Blah.class);
-        Blah blah3 = field3.getAnnotation(Blah.class);
-        assertTrue(AnnotationUtils.equals(blah1, blah2));
-        assertFalse(AnnotationUtils.equals(blah1, blah3));
-    }
 }



Mime
View raw message