Skip to content

Commit

Permalink
Review: Unify use of ANONYMOUS_CLASSES predicate
Browse files Browse the repository at this point in the history
In `PublicAPIRules` we can now also use the predefined `JavaClass.Predicates.ANONYMOUS_CLASSES`.

Signed-off-by: Peter Gafert <[email protected]>
  • Loading branch information
codecholeric committed Jan 10, 2020
1 parent 0fd7cd3 commit 222ccd2
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static com.tngtech.archunit.base.DescribedPredicate.anyElementThat;
import static com.tngtech.archunit.base.DescribedPredicate.doNot;
import static com.tngtech.archunit.base.DescribedPredicate.not;
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.ANONYMOUS_CLASSES;
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.assignableTo;
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.equivalentTo;
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage;
Expand Down Expand Up @@ -188,15 +189,6 @@ private boolean enumMethod(JavaMethod methodToCheck, String name, Class<?>... pa
};
}

private static DescribedPredicate<JavaClass> anonymousClass() {
return new DescribedPredicate<JavaClass>("anonymous class") {
@Override
public boolean apply(JavaClass input) {
return input.isAnonymousClass();
}
};
}

private static DescribedPredicate<JavaMember> declaredInClassIn(String packageIdentifier) {
return declaredIn(resideInAPackage(packageIdentifier).as("class in '%s'", packageIdentifier));
}
Expand Down Expand Up @@ -286,7 +278,7 @@ private boolean isPublicAPISuperMethod(JavaMethod candidate, JavaMethod methodTo
private static DescribedPredicate<JavaMember> relevantArchUnitMembers() {
return not(inheritedFromObjectOrEnum())
.and(not(declaredIn(assignableTo(Annotation.class))))
.and(not(declaredIn(anonymousClass())))
.and(not(declaredIn(ANONYMOUS_CLASSES)))
.and(not(declaredIn(internal())))
.and(not(declaredInClassIn(THIRDPARTY_PACKAGE_IDENTIFIER)))
.as("relevant members");
Expand Down

0 comments on commit 222ccd2

Please sign in to comment.