retract @Nonbinding support; doesn't seem proper default behavior
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1083849 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
85b9694d48
commit
05510d7079
6
pom.xml
6
pom.xml
|
@ -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>
|
||||
|
|
|
@ -97,27 +97,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue