public interface ClassesShould
Modifier and Type | Method and Description |
---|---|
ClassesShouldThat |
accessClassesThat()
Asserts that all classes selected by this rule access certain classes.
NOTE: This usually makes more sense the negated way, e.g. |
ClassesShouldConjunction |
accessClassesThat(DescribedPredicate<? super JavaClass> predicate)
Asserts that all classes selected by this rule access certain classes.
NOTE: This usually makes more sense the negated way, e.g. |
ClassesShouldConjunction |
accessField(java.lang.Class<?> owner,
java.lang.String fieldName)
Matches against all accesses (setting or getting) of a specific field.
|
ClassesShouldConjunction |
accessField(java.lang.String ownerName,
java.lang.String fieldName)
Matches against all accesses (setting or getting) of a specific field.
|
ClassesShouldConjunction |
accessFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
Matches against accessing fields, where origin (a method or constructor) and target (a field)
can be freely restricted by the supplied predicate.
|
ClassesShouldConjunction |
accessTargetWhere(DescribedPredicate<? super JavaAccess<?>> predicate)
Matches against access of arbitrary targets (compare
AccessTarget )
where origin (a method or constructor) and target (a field, method or constructor) can be freely restricted
by the supplied predicate. |
ClassesShouldConjunction |
beAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are annotated with a certain type of annotation.
|
ClassesShouldConjunction |
beAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are annotated with a certain annotation, where matching annotations are
determined by the supplied predicate.
|
ClassesShouldConjunction |
beAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are annotated with a certain type of annotation.
|
ClassesShouldConjunction |
beAssignableFrom(java.lang.Class<?> type)
Asserts that classes are assignable from a certain type (compare
Class.isAssignableFrom(Class) to terminology). |
ClassesShouldConjunction |
beAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable from a certain type matching the given predicate.
|
ClassesShouldConjunction |
beAssignableFrom(java.lang.String typeName)
Asserts that classes are assignable from a certain type with the given type name.
|
ClassesShouldConjunction |
beAssignableTo(java.lang.Class<?> type)
Asserts that classes are assignable to a certain type (compare
Class.isAssignableFrom(Class) to terminology). |
ClassesShouldConjunction |
beAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable to a certain type matching the given predicate.
|
ClassesShouldConjunction |
beAssignableTo(java.lang.String typeName)
Asserts that classes are assignable to a certain type with the given type name.
|
ClassesShouldConjunction |
beInterfaces()
Asserts that classes are interfaces.
|
ClassesShouldConjunction |
bePackagePrivate()
Asserts that classes are package private.
|
ClassesShouldConjunction |
bePrivate()
Asserts that classes are private.
|
ClassesShouldConjunction |
beProtected()
Asserts that classes are protected.
|
ClassesShouldConjunction |
bePublic()
Asserts that classes are public.
|
ClassesShouldConjunction |
callCodeUnitWhere(DescribedPredicate<? super JavaCall<?>> predicate)
Matches against code unit calls (compare
JavaCodeUnit ) where origin (a code unit)
and target (a code unit) can be freely restricted by the supplied predicate. |
ClassesShouldConjunction |
callConstructor(java.lang.Class<?> owner,
java.lang.Class<?>... parameterTypes)
Matches against a constructor call to a specific constructor (e.g.
|
ClassesShouldConjunction |
callConstructor(java.lang.String ownerName,
java.lang.String... parameterTypeNames)
Matches against constructor call to a specific constructor (e.g.
|
ClassesShouldConjunction |
callConstructorWhere(DescribedPredicate<? super JavaConstructorCall> predicate)
Matches against constructor calls where origin (a method or constructor) and target (a constructor)
can be freely restricted by the supplied predicate.
|
ClassesShouldConjunction |
callMethod(java.lang.Class<?> owner,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Matches against a method call to a specific method (e.g.
|
ClassesShouldConjunction |
callMethod(java.lang.String ownerName,
java.lang.String methodName,
java.lang.String... parameterTypeNames)
Matches against method call to a specific method (e.g.
|
ClassesShouldConjunction |
callMethodWhere(DescribedPredicate<? super JavaMethodCall> predicate)
Matches against method calls where origin (a method or constructor) and target (a method)
can be freely restricted by the supplied predicate.
|
ClassesShouldConjunction |
getField(java.lang.Class<?> owner,
java.lang.String fieldName)
Matches against getting of a specific field (e.g.
|
ClassesShouldConjunction |
getField(java.lang.String ownerName,
java.lang.String fieldName)
Matches against getting a specific field (e.g.
|
ClassesShouldConjunction |
getFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
Matches against getting of fields, where origin (a method or constructor) and target (a field)
can be freely restricted by the supplied predicate.
|
ClassesShouldConjunction |
haveFullyQualifiedName(java.lang.String name)
Asserts that classes have a certain fully qualified class name.
|
ClassesShouldConjunction |
haveModifier(JavaModifier modifier)
Asserts that classes have a certain
JavaModifier (e.g. |
ClassesShouldConjunction |
haveNameMatching(java.lang.String regex)
Asserts that classes have a fully qualified class name matching a given regular expression.
|
ClassesShouldConjunction |
haveNameNotMatching(java.lang.String regex)
Asserts that classes have a fully qualified class name not matching a given regular expression.
|
ClassesShouldConjunction |
haveSimpleName(java.lang.String name)
Asserts that classes have a certain simple class name.
|
ClassesShouldConjunction |
haveSimpleNameContaining(java.lang.String infix)
Asserts that classes' simple class names contain the specified infix.
|
ClassesShouldConjunction |
haveSimpleNameEndingWith(java.lang.String suffix)
Asserts that classes' simple class names end with a given suffix.
|
ClassesShouldConjunction |
haveSimpleNameNotContaining(java.lang.String infix)
Asserts that classes' simple class names do not contain the specified infix.
|
ClassesShouldConjunction |
haveSimpleNameNotEndingWith(java.lang.String suffix)
Asserts that classes' simple class names do not end with a given suffix.
|
ClassesShouldConjunction |
haveSimpleNameNotStartingWith(java.lang.String prefix)
Asserts that classes' simple class names do not start with a given prefix.
|
ClassesShouldConjunction |
haveSimpleNameStartingWith(java.lang.String prefix)
Asserts that classes' simple class names start with a given prefix.
|
ClassesShouldConjunction |
implement(java.lang.Class<?> type)
Asserts that classes implement a certain interface.
|
ClassesShouldConjunction |
implement(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes implement a certain interface matching the given predicate.
|
ClassesShouldConjunction |
implement(java.lang.String typeName)
Asserts that classes implement a certain interface with the given type name.
|
ClassesShouldConjunction |
notBeAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are not annotated with a certain type of annotation.
|
ClassesShouldConjunction |
notBeAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are not annotated with a certain annotation, where matching annotations are
determined by the supplied predicate.
|
ClassesShouldConjunction |
notBeAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are not annotated with a certain type of annotation.
|
ClassesShouldConjunction |
notBeAssignableFrom(java.lang.Class<?> type)
Asserts that classes are not assignable from a certain type.
|
ClassesShouldConjunction |
notBeAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable from a certain type matching the given predicate.
|
ClassesShouldConjunction |
notBeAssignableFrom(java.lang.String typeName)
Asserts that classes are not assignable from a certain type with the given type name.
|
ClassesShouldConjunction |
notBeAssignableTo(java.lang.Class<?> type)
Asserts that classes are not assignable to a certain type.
|
ClassesShouldConjunction |
notBeAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable to a certain type matching the given predicate.
|
ClassesShouldConjunction |
notBeAssignableTo(java.lang.String typeName)
Asserts that classes are not assignable to a certain type with the given type name.
|
ClassesShouldConjunction |
notBeInterfaces()
Asserts that classes are not interfaces.
|
ClassesShouldConjunction |
notBePackagePrivate()
Asserts that classes are non-package private.
|
ClassesShouldConjunction |
notBePrivate()
Asserts that classes are non-private.
|
ClassesShouldConjunction |
notBeProtected()
Asserts that classes are non-protected.
|
ClassesShouldConjunction |
notBePublic()
Asserts that classes are non-public.
|
ClassesShouldConjunction |
notHaveFullyQualifiedName(java.lang.String name)
Asserts that classes don't have a certain fully qualified class name.
|
ClassesShouldConjunction |
notHaveModifier(JavaModifier modifier)
Asserts that classes don't have a certain
JavaModifier (e.g. |
ClassesShouldConjunction |
notHaveSimpleName(java.lang.String name)
Asserts that classes don't have a certain simple class name.
|
ClassesShouldConjunction |
notImplement(java.lang.Class<?> type)
Asserts that classes don't implement a certain interface.
|
ClassesShouldConjunction |
notImplement(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes don't implement a certain interface matching the given predicate.
|
ClassesShouldConjunction |
notImplement(java.lang.String typeName)
Asserts that classes don't implement a certain interface with the given type name.
|
OnlyBeAccessedSpecification<ClassesShouldConjunction> |
onlyBeAccessed() |
ClassesShouldConjunction |
resideInAnyPackage(java.lang.String... packageIdentifiers)
Asserts that classes reside in a package matching any of the supplied package identifiers.
|
ClassesShouldConjunction |
resideInAPackage(java.lang.String packageIdentifier)
Asserts that classes reside in a package matching the supplied package identifier.
|
ClassesShouldConjunction |
resideOutsideOfPackage(java.lang.String packageIdentifier)
Asserts that classes don't reside in a package matching the supplied package identifier.
|
ClassesShouldConjunction |
resideOutsideOfPackages(java.lang.String... packageIdentifiers)
Asserts that classes don't reside in a package matching any of the supplied package identifiers.
|
ClassesShouldConjunction |
setField(java.lang.Class<?> owner,
java.lang.String fieldName)
Matches against setting a specific field (e.g.
|
ClassesShouldConjunction |
setField(java.lang.String ownerName,
java.lang.String fieldName)
Matches against setting a specific field (e.g.
|
ClassesShouldConjunction |
setFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
Matches against setting of fields, where origin (a method or constructor) and target (a field)
can be freely restricted by the supplied predicate.
|
ClassesShouldConjunction haveFullyQualifiedName(java.lang.String name)
name
- The fully qualified class nameClassesShouldConjunction notHaveFullyQualifiedName(java.lang.String name)
name
- The fully qualified class nameClassesShouldConjunction haveSimpleName(java.lang.String name)
name
- The simple class nameClassesShouldConjunction notHaveSimpleName(java.lang.String name)
name
- The simple class nameClassesShouldConjunction haveSimpleNameStartingWith(java.lang.String prefix)
prefix
- A prefix the simple class name should start withClassesShouldConjunction haveSimpleNameNotStartingWith(java.lang.String prefix)
prefix
- A prefix the simple class name should not start withClassesShouldConjunction haveSimpleNameContaining(java.lang.String infix)
infix
- An infix the simple class name should containClassesShouldConjunction haveSimpleNameNotContaining(java.lang.String infix)
infix
- An infix the simple class name should not containClassesShouldConjunction haveSimpleNameEndingWith(java.lang.String suffix)
suffix
- A suffix the simple class name should end withClassesShouldConjunction haveSimpleNameNotEndingWith(java.lang.String suffix)
suffix
- A suffix the simple class name should not end withClassesShouldConjunction haveNameMatching(java.lang.String regex)
regex
- A regular expressionClassesShouldConjunction haveNameNotMatching(java.lang.String regex)
regex
- A regular expressionClassesShouldConjunction resideInAPackage(java.lang.String packageIdentifier)
packageIdentifier
- A string identifying packages, for details see PackageMatcher
ClassesShouldConjunction resideInAnyPackage(java.lang.String... packageIdentifiers)
packageIdentifiers
- Strings identifying packages, for details see PackageMatcher
ClassesShouldConjunction resideOutsideOfPackage(java.lang.String packageIdentifier)
packageIdentifier
- A string identifying packages, for details see PackageMatcher
ClassesShouldConjunction resideOutsideOfPackages(java.lang.String... packageIdentifiers)
packageIdentifiers
- Strings identifying packages, for details see PackageMatcher
ClassesShouldConjunction bePublic()
ClassesShouldConjunction notBePublic()
ClassesShouldConjunction beProtected()
ClassesShouldConjunction notBeProtected()
ClassesShouldConjunction bePackagePrivate()
ClassesShouldConjunction notBePackagePrivate()
ClassesShouldConjunction bePrivate()
ClassesShouldConjunction notBePrivate()
ClassesShouldConjunction haveModifier(JavaModifier modifier)
JavaModifier
(e.g. JavaModifier.ABSTRACT
).ClassesShouldConjunction notHaveModifier(JavaModifier modifier)
JavaModifier
(e.g. JavaModifier.ABSTRACT
).ClassesShouldConjunction beAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
- Specific type of Annotation
ClassesShouldConjunction notBeAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
- Specific type of Annotation
ClassesShouldConjunction beAnnotatedWith(java.lang.String annotationTypeName)
annotationTypeName
- Fully qualified class name of a specific type of Annotation
ClassesShouldConjunction notBeAnnotatedWith(java.lang.String annotationTypeName)
annotationTypeName
- Fully qualified class name of a specific type of Annotation
ClassesShouldConjunction beAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
predicate
- A predicate defining matching JavaAnnotations
ClassesShouldConjunction notBeAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
predicate
- A predicate defining matching JavaAnnotations
ClassesShouldConjunction implement(java.lang.Class<?> type)
type
- An interface imported classes should implementClassesShouldConjunction notImplement(java.lang.Class<?> type)
implement(Class)
.type
- An interface imported classes should NOT implementClassesShouldConjunction implement(java.lang.String typeName)
implement(Class)
, but doesn't depend on having a certain type on the classpath.typeName
- Name of an interface imported classes should implementClassesShouldConjunction notImplement(java.lang.String typeName)
notImplement(Class)
, but doesn't depend on having a certain
type on the classpath.typeName
- Name of an interface imported classes should NOT implementClassesShouldConjunction implement(DescribedPredicate<? super JavaClass> predicate)
HasName.Predicates.name(String)
would be equivalent to
implement(String)
, but the approach is a lot more generic.predicate
- A predicate identifying an interface imported classes should implementClassesShouldConjunction notImplement(DescribedPredicate<? super JavaClass> predicate)
implement(DescribedPredicate)
.predicate
- A predicate identifying an interface imported classes should NOT implementClassesShouldConjunction beAssignableTo(java.lang.Class<?> type)
Class.isAssignableFrom(Class)
to terminology).
A simple example for this predicate would be
assignableTo(Object.class).apply(importedStringClass); // --> returns true
assignableTo(String.class).apply(importedStringClass); // --> returns true
assignableTo(List.class).apply(importedStringClass); // --> returns false
type
- An upper type bound to match imported classes against (imported subtypes will match)ClassesShouldConjunction notBeAssignableTo(java.lang.Class<?> type)
beAssignableTo(Class)
.type
- An upper type bound imported classes should NOT haveClassesShouldConjunction beAssignableTo(java.lang.String typeName)
beAssignableTo(Class)
, but doesn't depend on having a certain type on the classpath.typeName
- Name of an upper type bound to match imported classes against (imported subtypes will match)ClassesShouldConjunction notBeAssignableTo(java.lang.String typeName)
notBeAssignableTo(Class)
, but doesn't depend on having a certain
type on the classpath.typeName
- Name of an upper type bound imported classes should NOT haveClassesShouldConjunction beAssignableTo(DescribedPredicate<? super JavaClass> predicate)
HasName.Predicates.name(String)
would be equivalent to
beAssignableTo(String)
, but the approach is a lot more generic.predicate
- A predicate identifying an upper type bound to match imported classes against
(imported subtypes will match)ClassesShouldConjunction notBeAssignableTo(DescribedPredicate<? super JavaClass> predicate)
beAssignableTo(DescribedPredicate)
.predicate
- A predicate identifying an upper type bound imported classes should NOT haveClassesShouldConjunction beAssignableFrom(java.lang.Class<?> type)
Class.isAssignableFrom(Class)
to terminology).
This is roughly equivalent to the use of reflection:
someClass.class.isAssignableFrom(type);
A simple example for this predicate would be
assignableFrom(ArrayList.class).apply(importedArrayListClass); // --> returns true
assignableFrom(ArrayList.class).apply(importedListClass); // --> returns true
assignableFrom(ArrayList.class).apply(importedStringClass); // --> returns false
type
- A lower type bound to match imported classes against (imported supertypes will match)ClassesShouldConjunction notBeAssignableFrom(java.lang.Class<?> type)
beAssignableFrom(Class)
.type
- A lower type bound imported classes should NOT haveClassesShouldConjunction beAssignableFrom(java.lang.String typeName)
beAssignableFrom(Class)
, but doesn't depend on having a certain type on the classpath.typeName
- Name of a lower type bound to match imported classes against (imported supertypes will match)ClassesShouldConjunction notBeAssignableFrom(java.lang.String typeName)
notBeAssignableFrom(Class)
, but doesn't depend on having a certain
type on the classpath.typeName
- Name of a lower type bound imported classes should NOT haveClassesShouldConjunction beAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
HasName.Predicates.name(String)
would be equivalent to
beAssignableFrom(String)
, but the approach is a lot more generic.predicate
- A predicate identifying a lower type bound to match imported classes against
(imported supertypes will match)ClassesShouldConjunction notBeAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
beAssignableFrom(DescribedPredicate)
.predicate
- A predicate identifying a lower type bound imported classes should NOT haveClassesShouldConjunction accessField(java.lang.Class<?> owner, java.lang.String fieldName)
owner
- The class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction accessField(java.lang.String ownerName, java.lang.String fieldName)
ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction accessFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
predicate
- Determines which JavaFieldAccesses
match the ruleClassesShouldConjunction getField(java.lang.Class<?> owner, java.lang.String fieldName)
return someClass.someField;
).owner
- The class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction getField(java.lang.String ownerName, java.lang.String fieldName)
return someClass.someField;
).ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction getFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
predicate
- Determines which JavaFieldAccesses
match the ruleClassesShouldConjunction setField(java.lang.Class<?> owner, java.lang.String fieldName)
someClass.someField = newValue;
).owner
- The class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction setField(java.lang.String ownerName, java.lang.String fieldName)
someClass.someField = newValue;
).ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to matchClassesShouldConjunction setFieldWhere(DescribedPredicate<? super JavaFieldAccess> predicate)
predicate
- Determines which JavaFieldAccesses
match the ruleClassesShouldConjunction callMethod(java.lang.Class<?> owner, java.lang.String methodName, java.lang.Class<?>... parameterTypes)
someClass.call();
).owner
- Class declaring the methodmethodName
- The method name to match againstparameterTypes
- The parameter types of the respective methodClassesShouldConjunction callMethod(java.lang.String ownerName, java.lang.String methodName, java.lang.String... parameterTypeNames)
someClass.call();
).ownerName
- The fully qualified class name declaring the methodmethodName
- The method name to match againstparameterTypeNames
- The fully qualified parameter type namesClassesShouldConjunction callMethodWhere(DescribedPredicate<? super JavaMethodCall> predicate)
predicate
- Determines which JavaMethodCalls
match the ruleClassesShouldConjunction callConstructor(java.lang.Class<?> owner, java.lang.Class<?>... parameterTypes)
new SomeClass();
).owner
- Class declaring the constructorparameterTypes
- The parameter types of the respective constructorClassesShouldConjunction callConstructor(java.lang.String ownerName, java.lang.String... parameterTypeNames)
new SomeClass();
).ownerName
- The fully qualified class name declaring the constructorparameterTypeNames
- The fully qualified parameter type namesClassesShouldConjunction callConstructorWhere(DescribedPredicate<? super JavaConstructorCall> predicate)
predicate
- Determines which JavaConstructorCalls
match the ruleClassesShouldConjunction accessTargetWhere(DescribedPredicate<? super JavaAccess<?>> predicate)
AccessTarget
)
where origin (a method or constructor) and target (a field, method or constructor) can be freely restricted
by the supplied predicate.predicate
- Determines which JavaAccesses
match the ruleClassesShouldConjunction callCodeUnitWhere(DescribedPredicate<? super JavaCall<?>> predicate)
JavaCodeUnit
) where origin (a code unit)
and target (a code unit) can be freely restricted by the supplied predicate.predicate
- Determines which JavaCalls
match the ruleClassesShouldThat accessClassesThat()
noClasses()
.should()
.accessClassesThat()
.haveFullyQualifiedName(String)
ClassesShouldConjunction accessClassesThat(DescribedPredicate<? super JavaClass> predicate)
noClasses()
.should()
.accessClassesThat(myPredicate)
predicate
- Determines which JavaClasses
match the access targetOnlyBeAccessedSpecification<ClassesShouldConjunction> onlyBeAccessed()
onlyBeAccessed()
.byAnyPackage(String...)
ClassesShouldConjunction beInterfaces()
ClassesShouldConjunction notBeInterfaces()