Skip to content

Commit

Permalink
LANG-1317 Removes the priority parameter of getAllSuperclassesAndInte…
Browse files Browse the repository at this point in the history
…rfaces
  • Loading branch information
yasserzamani committed Apr 20, 2017
1 parent b79fe6f commit 90e252f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
13 changes: 2 additions & 11 deletions src/main/java/org/apache/commons/lang3/ClassUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ public enum Interfaces {
INCLUDE, EXCLUDE
}

/**
* Inclusivity literals for {@link #getAllSuperclassesAndInterfaces(Class, Priority)}.
* @since 3.6
*/
public enum Priority {
SUPERCLASS, INTERFACE
}

/**
* The package separator character: <code>'&#x2e;' == {@value}</code>.
*/
Expand Down Expand Up @@ -470,11 +462,10 @@ public static List<Class<?>> getAllInterfaces(final Class<?> cls) {
* from interfaces, and so on in a breadth first way.</p>
*
* @param cls the class to look up, may be {@code null}
* @param p determines what to peek in same breadth, the superclass or interface
* @return the {@code List} of superclasses in order going up from this one
* {@code null} if null input
*/
public static List<Class<?>> getAllSuperclassesAndInterfaces(final Class<?> cls, Priority p) {
public static List<Class<?>> getAllSuperclassesAndInterfaces(final Class<?> cls) {
if (cls == null) {
return null;
}
Expand All @@ -496,7 +487,7 @@ public static List<Class<?>> getAllSuperclassesAndInterfaces(final Class<?> cls,
} else if (sci < ifi) {
acls = allSuperclasses.get(sci++);
} else {
acls = (p == Priority.SUPERCLASS ? allSuperclasses.get(sci++) : allInterfaces.get(ifi++));
acls = allInterfaces.get(ifi++);
}
classes.add(acls);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ public static List<Method> getMethodsListWithAnnotation(final Class<?> cls,

Validate.isTrue(cls != null, "The class must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
List<Class<?>> classes = (searchSupers ? ClassUtils.getAllSuperclassesAndInterfaces(cls,
ClassUtils.Priority.INTERFACE) : new ArrayList<Class<?>>());
List<Class<?>> classes = (searchSupers ? ClassUtils.getAllSuperclassesAndInterfaces(cls)
: new ArrayList<Class<?>>());
classes.add(0, cls);
final List<Method> annotatedMethods = new ArrayList<>();
for (Class<?> acls : classes) {
Expand Down Expand Up @@ -954,7 +954,7 @@ public static <A extends Annotation> A getAnnotation(final Method method, final

if(annotation == null && searchSupers) {
Class<?> mcls = method.getDeclaringClass();
List<Class<?>> classes = ClassUtils.getAllSuperclassesAndInterfaces(mcls, ClassUtils.Priority.INTERFACE);
List<Class<?>> classes = ClassUtils.getAllSuperclassesAndInterfaces(mcls);
for (Class<?> acls : classes) {
Method equivalentMethod;
try {
Expand Down
22 changes: 3 additions & 19 deletions src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ public void test_getAllInterfaces_Class() {
}

@Test
public void test_getAllSuperclassesAndInterfacesPriorityINTERFACE_Class() {
final List<?> list = ClassUtils.getAllSuperclassesAndInterfaces(CY.class, ClassUtils.Priority.INTERFACE);
public void test_getAllSuperclassesAndInterfaces_Class() {
final List<?> list = ClassUtils.getAllSuperclassesAndInterfaces(CY.class);
assertEquals(8, list.size());
assertEquals(IB.class, list.get(0));
assertEquals(CX.class, list.get(1));
Expand All @@ -294,23 +294,7 @@ public void test_getAllSuperclassesAndInterfacesPriorityINTERFACE_Class() {
assertEquals(IF.class, list.get(6));
assertEquals(IA.class, list.get(7));

assertEquals(null, ClassUtils.getAllSuperclassesAndInterfaces(null, ClassUtils.Priority.INTERFACE));
}

@Test
public void test_getAllSuperclassesAndInterfacesPrioritySUPERCLASS_Class() {
final List<?> list = ClassUtils.getAllSuperclassesAndInterfaces(CY.class, ClassUtils.Priority.SUPERCLASS);
assertEquals(8, list.size());
assertEquals(CX.class, list.get(0));
assertEquals(IB.class, list.get(1));
assertEquals(Object.class, list.get(2));
assertEquals(IC.class, list.get(3));
assertEquals(ID.class, list.get(4));
assertEquals(IE.class, list.get(5));
assertEquals(IF.class, list.get(6));
assertEquals(IA.class, list.get(7));

assertEquals(null, ClassUtils.getAllSuperclassesAndInterfaces(null, ClassUtils.Priority.SUPERCLASS));
assertEquals(null, ClassUtils.getAllSuperclassesAndInterfaces(null));
}

private static interface IA {
Expand Down

0 comments on commit 90e252f

Please sign in to comment.