Package com.tngtech.archunit.core.domain
Class JavaClass.Predicates
java.lang.Object
com.tngtech.archunit.core.domain.JavaClass.Predicates
- Enclosing class:
- JavaClass
public static final class JavaClass.Predicates
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static DescribedPredicate<JavaClass>
ANNOTATIONS
static DescribedPredicate<JavaClass>
ANONYMOUS_CLASSES
static DescribedPredicate<JavaClass>
ENUMS
static DescribedPredicate<JavaClass>
INNER_CLASSES
static DescribedPredicate<JavaClass>
INTERFACES
static DescribedPredicate<JavaClass>
LOCAL_CLASSES
static DescribedPredicate<JavaClass>
MEMBER_CLASSES
static DescribedPredicate<JavaClass>
NESTED_CLASSES
static DescribedPredicate<JavaClass>
RECORDS
static DescribedPredicate<JavaClass>
TOP_LEVEL_CLASSES
-
Method Summary
Modifier and Type Method Description static DescribedPredicate<JavaClass>
assignableFrom(DescribedPredicate<? super JavaClass> predicate)
Same asassignableFrom(Class)
, but returnstrue
whenever the testedJavaClass
is assignable from a class that matches the supplied predicate.
This is the opposite ofassignableTo(DescribedPredicate)
: some classB
is assignable from a classA
if and only ifA
is assignable toA
.static DescribedPredicate<JavaClass>
assignableFrom(java.lang.Class<?> type)
static DescribedPredicate<JavaClass>
assignableFrom(java.lang.String typeName)
Same asassignableFrom(Class)
but takes a fully qualified class name as an argument instead of a class object.static DescribedPredicate<JavaClass>
assignableTo(DescribedPredicate<? super JavaClass> predicate)
Same asassignableTo(Class)
, but returnstrue
whenever the testedJavaClass
is assignable to a class that matches the supplied predicate.
This is the opposite ofassignableFrom(DescribedPredicate)
: some classA
is assignable to a classB
if and only ifB
is assignable fromA
.static DescribedPredicate<JavaClass>
assignableTo(java.lang.Class<?> type)
static DescribedPredicate<JavaClass>
assignableTo(java.lang.String typeName)
Same asassignableTo(Class)
but takes a fully qualified class name as an argument instead of a class object.static DescribedPredicate<JavaClass>
belongToAnyOf(java.lang.Class<?>... classes)
A predicate to determine if aJavaClass
"belongs" to one of the passedclasses
, where we define "belong" as being equivalent to the class itself or any inner/anonymous class of this class.static DescribedPredicate<JavaClass>
containAnyCodeUnitsThat(DescribedPredicate<? super JavaCodeUnit> predicate)
A predicate to determine if aJavaClass
contains one or morecode units
matching the supplied predicate.static DescribedPredicate<JavaClass>
containAnyConstructorsThat(DescribedPredicate<? super JavaConstructor> predicate)
A predicate to determine if aJavaClass
contains one or moreconstructors
matching the supplied predicate.static DescribedPredicate<JavaClass>
containAnyFieldsThat(DescribedPredicate<? super JavaField> predicate)
static DescribedPredicate<JavaClass>
containAnyMembersThat(DescribedPredicate<? super JavaMember> predicate)
static DescribedPredicate<JavaClass>
containAnyMethodsThat(DescribedPredicate<? super JavaMethod> predicate)
static DescribedPredicate<JavaClass>
containAnyStaticInitializersThat(DescribedPredicate<? super JavaStaticInitializer> predicate)
A predicate to determine if aJavaClass
contains one or moreconstructors
matching the supplied predicate.static DescribedPredicate<JavaClass>
equivalentTo(java.lang.Class<?> clazz)
static DescribedPredicate<JavaClass>
implement(DescribedPredicate<? super JavaClass> predicate)
Same asimplement(Class)
but returnstrue
whenever the testedJavaClass
implements an interface that matches the supplied predicate.static DescribedPredicate<JavaClass>
implement(java.lang.Class<?> type)
static DescribedPredicate<JavaClass>
implement(java.lang.String typeName)
Same asimplement(Class)
but takes a fully qualified class name as an argument instead of a class object.static DescribedPredicate<JavaClass>
resideInAnyPackage(java.lang.String... packageIdentifiers)
static DescribedPredicate<JavaClass>
resideInAPackage(java.lang.String packageIdentifier)
Offers a syntax to identify packages similar to AspectJ.static DescribedPredicate<JavaClass>
resideOutsideOfPackage(java.lang.String packageIdentifier)
static DescribedPredicate<JavaClass>
resideOutsideOfPackages(java.lang.String... packageIdentifiers)
static DescribedPredicate<JavaClass>
simpleName(java.lang.String name)
static DescribedPredicate<JavaClass>
simpleNameContaining(java.lang.String infix)
static DescribedPredicate<JavaClass>
simpleNameEndingWith(java.lang.String suffix)
static DescribedPredicate<JavaClass>
simpleNameStartingWith(java.lang.String prefix)
static DescribedPredicate<JavaClass>
type(java.lang.Class<?> type)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
INTERFACES
-
ENUMS
-
ANNOTATIONS
-
RECORDS
-
TOP_LEVEL_CLASSES
-
NESTED_CLASSES
-
MEMBER_CLASSES
-
INNER_CLASSES
-
LOCAL_CLASSES
-
ANONYMOUS_CLASSES
-
-
Method Details
-
type
-
simpleName
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> simpleName(java.lang.String name) -
simpleNameStartingWith
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> simpleNameStartingWith(java.lang.String prefix) -
simpleNameContaining
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> simpleNameContaining(java.lang.String infix) -
simpleNameEndingWith
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> simpleNameEndingWith(java.lang.String suffix) -
assignableTo
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableTo(java.lang.Class<?> type)- Parameters:
type
- the type to check for assignability- Returns:
- a
DescribedPredicate
that returnstrue
, if the respectiveJavaClass
is assignable to the suppliedtype
. I.e. the type represented by the testedJavaClass
could be casted to the suppliedtype
.
This is the opposite ofassignableFrom(Class)
: some classA
is assignable to a classB
if and only ifB
is assignable fromA
. - See Also:
assignableTo(String)
,assignableTo(DescribedPredicate)
,assignableFrom(Class)
-
assignableFrom
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableFrom(java.lang.Class<?> type)- Parameters:
type
- the type to check for assignability- Returns:
- a
DescribedPredicate
that returnstrue
, if the respectiveJavaClass
is assignable from the suppliedtype
. I.e. the suppliedtype
could be casted to the type represented by the testedJavaClass
.
This is the opposite ofassignableTo(Class)
: some classB
is assignable from a classA
if and only ifA
is assignable toB
. - See Also:
assignableFrom(String)
,assignableFrom(DescribedPredicate)
,assignableTo(Class)
-
assignableTo
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableTo(java.lang.String typeName)Same asassignableTo(Class)
but takes a fully qualified class name as an argument instead of a class object. -
assignableFrom
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableFrom(java.lang.String typeName)Same asassignableFrom(Class)
but takes a fully qualified class name as an argument instead of a class object. -
assignableTo
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableTo(DescribedPredicate<? super JavaClass> predicate)Same asassignableTo(Class)
, but returnstrue
whenever the testedJavaClass
is assignable to a class that matches the supplied predicate.
This is the opposite ofassignableFrom(DescribedPredicate)
: some classA
is assignable to a classB
if and only ifB
is assignable fromA
. -
assignableFrom
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> assignableFrom(DescribedPredicate<? super JavaClass> predicate)Same asassignableFrom(Class)
, but returnstrue
whenever the testedJavaClass
is assignable from a class that matches the supplied predicate.
This is the opposite ofassignableTo(DescribedPredicate)
: some classB
is assignable from a classA
if and only ifA
is assignable toA
. -
implement
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> implement(java.lang.Class<?> type)- Parameters:
type
- the interface type to check for- Returns:
- a
DescribedPredicate
that returnstrue
if the testedJavaClass
implements the supplied interfacetype
. I.e. the suppliedtype
must be an interface and the testedJavaClass
must be a class (it resembles delarations likeclass A implements B
, which only works for a classA
and an interfaceB
). - Throws:
ArchUnitException.InvalidSyntaxUsageException
- iftype
is not an interface- See Also:
implement(String)
,implement(DescribedPredicate)
,assignableTo(Class)
-
implement
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> implement(java.lang.String typeName)Same asimplement(Class)
but takes a fully qualified class name as an argument instead of a class object. -
implement
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> implement(DescribedPredicate<? super JavaClass> predicate)Same asimplement(Class)
but returnstrue
whenever the testedJavaClass
implements an interface that matches the supplied predicate. -
resideInAPackage
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> resideInAPackage(java.lang.String packageIdentifier)Offers a syntax to identify packages similar to AspectJ. In particular '*' stands for any sequence of characters, '..' stands for any sequence of packages. For further details seePackageMatcher
.- Parameters:
packageIdentifier
- A string representing the identifier to match packages against- Returns:
- A
DescribedPredicate
returningtrue
if and only if the package of the testedJavaClass
matches the identifier
-
resideInAnyPackage
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> resideInAnyPackage(java.lang.String... packageIdentifiers)- See Also:
resideInAPackage(String)
-
resideOutsideOfPackage
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> resideOutsideOfPackage(java.lang.String packageIdentifier) -
resideOutsideOfPackages
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> resideOutsideOfPackages(java.lang.String... packageIdentifiers) -
equivalentTo
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> equivalentTo(java.lang.Class<?> clazz)- See Also:
JavaClass.isEquivalentTo(Class)
-
belongToAnyOf
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> belongToAnyOf(java.lang.Class<?>... classes)A predicate to determine if aJavaClass
"belongs" to one of the passedclasses
, where we define "belong" as being equivalent to the class itself or any inner/anonymous class of this class.- Parameters:
classes
- Theclasses
to check theJavaClass
against- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
is equivalent to one of the suppliedclasses
or to one of its inner/anonymous classes.
-
containAnyMembersThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyMembersThat(DescribedPredicate<? super JavaMember> predicate)A predicate to determine if aJavaClass
contains one or moremembers
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
members.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one member matching the given predicate.
-
containAnyFieldsThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyFieldsThat(DescribedPredicate<? super JavaField> predicate)A predicate to determine if aJavaClass
contains one or morefields
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
fields.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one field matching the given predicate.
-
containAnyCodeUnitsThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyCodeUnitsThat(DescribedPredicate<? super JavaCodeUnit> predicate)A predicate to determine if aJavaClass
contains one or morecode units
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
code units.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one code unit matching the given predicate.
-
containAnyMethodsThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyMethodsThat(DescribedPredicate<? super JavaMethod> predicate)A predicate to determine if aJavaClass
contains one or moremethods
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
methods.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one method matching the given predicate.
-
containAnyConstructorsThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyConstructorsThat(DescribedPredicate<? super JavaConstructor> predicate)A predicate to determine if aJavaClass
contains one or moreconstructors
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
constructors.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one constructor matching the given predicate.
-
containAnyStaticInitializersThat
@PublicAPI(usage=ACCESS) public static DescribedPredicate<JavaClass> containAnyStaticInitializersThat(DescribedPredicate<? super JavaStaticInitializer> predicate)A predicate to determine if aJavaClass
contains one or moreconstructors
matching the supplied predicate.- Parameters:
predicate
- The predicate to check against theclasses'
constructors.- Returns:
- A
DescribedPredicate
returning true, if and only if the testedJavaClass
contains at least one constructor matching the given predicate.
-