Interface ClassesShould
-
public interface ClassesShould
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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 (compareAccessTarget
) where origin (a method or constructor) and target (a field, method or constructor) can be freely restricted by the supplied predicate.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.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are annotated with a certain type of annotation.ClassesShouldConjunction
beAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are annotated with a certain type of annotation.ClassesShouldConjunction
beAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable from a certain type matching the given predicate.ClassesShouldConjunction
beAssignableFrom(java.lang.Class<?> type)
Asserts that classes are assignable from a certain type (compareClass.isAssignableFrom(Class)
to terminology).ClassesShouldConjunction
beAssignableFrom(java.lang.String typeName)
Asserts that classes are assignable from a certain type with the given type name.ClassesShouldConjunction
beAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable to a certain type matching the given predicate.ClassesShouldConjunction
beAssignableTo(java.lang.Class<?> type)
Asserts that classes are assignable to a certain type (compareClass.isAssignableFrom(Class)
to terminology).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
beMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are meta-annotated with a certain annotation, where matching meta-annotations are determined by the supplied predicate.ClassesShouldConjunction
beMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are meta-annotated with a certain type of annotation.ClassesShouldConjunction
beMetaAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are meta-annotated with a certain type of annotation.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 (compareJavaCodeUnit
) 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 certainJavaModifier
(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(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes implement a certain interface matching the given predicate.ClassesShouldConjunction
implement(java.lang.Class<?> type)
Asserts that classes implement a certain interface.ClassesShouldConjunction
implement(java.lang.String typeName)
Asserts that classes implement a certain interface with the given type name.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.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are not annotated with a certain type of annotation.ClassesShouldConjunction
notBeAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are not annotated with a certain type of annotation.ClassesShouldConjunction
notBeAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable from a certain type matching the given predicate.ClassesShouldConjunction
notBeAssignableFrom(java.lang.Class<?> type)
Asserts that classes are not assignable from a certain type.ClassesShouldConjunction
notBeAssignableFrom(java.lang.String typeName)
Asserts that classes are not assignable from a certain type with the given type name.ClassesShouldConjunction
notBeAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable to a certain type matching the given predicate.ClassesShouldConjunction
notBeAssignableTo(java.lang.Class<?> type)
Asserts that classes are not assignable to a certain type.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
notBeMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are not meta-annotated with a certain annotation, where matching meta-annotations are determined by the supplied predicate.ClassesShouldConjunction
notBeMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are not meta-annotated with a certain type of annotation.ClassesShouldConjunction
notBeMetaAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are not meta-annotated with a certain type of annotation.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 certainJavaModifier
(e.g.ClassesShouldConjunction
notHaveSimpleName(java.lang.String name)
Asserts that classes don't have a certain simple class name.ClassesShouldConjunction
notImplement(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes don't implement a certain interface matching the given predicate.ClassesShouldConjunction
notImplement(java.lang.Class<?> type)
Asserts that classes don't implement a certain interface.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.
-
-
-
Method Detail
-
haveFullyQualifiedName
ClassesShouldConjunction haveFullyQualifiedName(java.lang.String name)
Asserts that classes have a certain fully qualified class name.- Parameters:
name
- The fully qualified class name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveFullyQualifiedName
ClassesShouldConjunction notHaveFullyQualifiedName(java.lang.String name)
Asserts that classes don't have a certain fully qualified class name.- Parameters:
name
- The fully qualified class name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleName
ClassesShouldConjunction haveSimpleName(java.lang.String name)
Asserts that classes have a certain simple class name.- Parameters:
name
- The simple class name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveSimpleName
ClassesShouldConjunction notHaveSimpleName(java.lang.String name)
Asserts that classes don't have a certain simple class name.- Parameters:
name
- The simple class name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameStartingWith
ClassesShouldConjunction haveSimpleNameStartingWith(java.lang.String prefix)
Asserts that classes' simple class names start with a given prefix.- Parameters:
prefix
- A prefix the simple class name should start with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameNotStartingWith
ClassesShouldConjunction haveSimpleNameNotStartingWith(java.lang.String prefix)
Asserts that classes' simple class names do not start with a given prefix.- Parameters:
prefix
- A prefix the simple class name should not start with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameContaining
ClassesShouldConjunction haveSimpleNameContaining(java.lang.String infix)
Asserts that classes' simple class names contain the specified infix.- Parameters:
infix
- An infix the simple class name should contain- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameNotContaining
ClassesShouldConjunction haveSimpleNameNotContaining(java.lang.String infix)
Asserts that classes' simple class names do not contain the specified infix.- Parameters:
infix
- An infix the simple class name should not contain- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameEndingWith
ClassesShouldConjunction haveSimpleNameEndingWith(java.lang.String suffix)
Asserts that classes' simple class names end with a given suffix.- Parameters:
suffix
- A suffix the simple class name should end with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveSimpleNameNotEndingWith
ClassesShouldConjunction haveSimpleNameNotEndingWith(java.lang.String suffix)
Asserts that classes' simple class names do not end with a given suffix.- Parameters:
suffix
- A suffix the simple class name should not end with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameMatching
ClassesShouldConjunction haveNameMatching(java.lang.String regex)
Asserts that classes have a fully qualified class name matching a given regular expression.- Parameters:
regex
- A regular expression- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameNotMatching
ClassesShouldConjunction haveNameNotMatching(java.lang.String regex)
Asserts that classes have a fully qualified class name not matching a given regular expression.- Parameters:
regex
- A regular expression- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
resideInAPackage
ClassesShouldConjunction resideInAPackage(java.lang.String packageIdentifier)
Asserts that classes reside in a package matching the supplied package identifier.- Parameters:
packageIdentifier
- A string identifying packages, for details seePackageMatcher
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
resideInAnyPackage
ClassesShouldConjunction resideInAnyPackage(java.lang.String... packageIdentifiers)
Asserts that classes reside in a package matching any of the supplied package identifiers.- Parameters:
packageIdentifiers
- Strings identifying packages, for details seePackageMatcher
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
resideOutsideOfPackage
ClassesShouldConjunction resideOutsideOfPackage(java.lang.String packageIdentifier)
Asserts that classes don't reside in a package matching the supplied package identifier.- Parameters:
packageIdentifier
- A string identifying packages, for details seePackageMatcher
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
resideOutsideOfPackages
ClassesShouldConjunction resideOutsideOfPackages(java.lang.String... packageIdentifiers)
Asserts that classes don't reside in a package matching any of the supplied package identifiers.- Parameters:
packageIdentifiers
- Strings identifying packages, for details seePackageMatcher
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
bePublic
ClassesShouldConjunction bePublic()
Asserts that classes are public.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePublic
ClassesShouldConjunction notBePublic()
Asserts that classes are non-public.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beProtected
ClassesShouldConjunction beProtected()
Asserts that classes are protected.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeProtected
ClassesShouldConjunction notBeProtected()
Asserts that classes are non-protected.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
bePackagePrivate
ClassesShouldConjunction bePackagePrivate()
Asserts that classes are package private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePackagePrivate
ClassesShouldConjunction notBePackagePrivate()
Asserts that classes are non-package private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
bePrivate
ClassesShouldConjunction bePrivate()
Asserts that classes are private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePrivate
ClassesShouldConjunction notBePrivate()
Asserts that classes are non-private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveModifier
ClassesShouldConjunction haveModifier(JavaModifier modifier)
Asserts that classes have a certainJavaModifier
(e.g.JavaModifier.ABSTRACT
).- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveModifier
ClassesShouldConjunction notHaveModifier(JavaModifier modifier)
Asserts that classes don't have a certainJavaModifier
(e.g.JavaModifier.ABSTRACT
).- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAnnotatedWith
ClassesShouldConjunction beAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are annotated with a certain type of annotation.- Parameters:
annotationType
- Specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAnnotatedWith
ClassesShouldConjunction notBeAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are not annotated with a certain type of annotation.- Parameters:
annotationType
- Specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAnnotatedWith
ClassesShouldConjunction beAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are annotated with a certain type of annotation.- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAnnotatedWith
ClassesShouldConjunction notBeAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are not annotated with a certain type of annotation.- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAnnotatedWith
ClassesShouldConjunction beAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are annotated with a certain annotation, where matching annotations are determined by the supplied predicate.- Parameters:
predicate
- A predicate defining matchingJavaAnnotations
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAnnotatedWith
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.- Parameters:
predicate
- A predicate defining matchingJavaAnnotations
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beMetaAnnotatedWith
ClassesShouldConjunction beMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
annotationType
- Specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeMetaAnnotatedWith
ClassesShouldConjunction notBeMetaAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Asserts that classes are not meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
annotationType
- Specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beMetaAnnotatedWith
ClassesShouldConjunction beMetaAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeMetaAnnotatedWith
ClassesShouldConjunction notBeMetaAnnotatedWith(java.lang.String annotationTypeName)
Asserts that classes are not meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
annotationTypeName
- Fully qualified class name of a specific type ofAnnotation
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beMetaAnnotatedWith
ClassesShouldConjunction beMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are meta-annotated with a certain annotation, where matching meta-annotations are determined by the supplied predicate. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
predicate
- A predicate defining matchingJavaAnnotations
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeMetaAnnotatedWith
ClassesShouldConjunction notBeMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation> predicate)
Asserts that classes are not meta-annotated with a certain annotation, where matching meta-annotations are determined by the supplied predicate. A meta-annotation is an annotation that is declared on another annotation.- Parameters:
predicate
- A predicate defining matchingJavaAnnotations
- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
implement
ClassesShouldConjunction implement(java.lang.Class<?> type)
Asserts that classes implement a certain interface.- Parameters:
type
- An interface imported classes should implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notImplement
ClassesShouldConjunction notImplement(java.lang.Class<?> type)
Asserts that classes don't implement a certain interface. This is the negation ofimplement(Class)
.- Parameters:
type
- An interface imported classes should NOT implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
implement
ClassesShouldConjunction implement(java.lang.String typeName)
Asserts that classes implement a certain interface with the given type name. This is equivalent toimplement(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of an interface imported classes should implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notImplement
ClassesShouldConjunction notImplement(java.lang.String typeName)
Asserts that classes don't implement a certain interface with the given type name. This is equivalent tonotImplement(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of an interface imported classes should NOT implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
implement
ClassesShouldConjunction implement(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes implement a certain interface matching the given predicate. For example, a call withHasName.Predicates.name(String)
would be equivalent toimplement(String)
, but the approach is a lot more generic.- Parameters:
predicate
- A predicate identifying an interface imported classes should implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notImplement
ClassesShouldConjunction notImplement(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes don't implement a certain interface matching the given predicate. This is the negation ofimplement(DescribedPredicate)
.- Parameters:
predicate
- A predicate identifying an interface imported classes should NOT implement- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableTo
ClassesShouldConjunction beAssignableTo(java.lang.Class<?> type)
Asserts that classes are assignable to a certain type (compareClass.isAssignableFrom(Class)
to terminology). A simple example for this predicate would beassignableTo(Object.class).apply(importedStringClass); // --> returns true assignableTo(String.class).apply(importedStringClass); // --> returns true assignableTo(List.class).apply(importedStringClass); // --> returns false
- Parameters:
type
- An upper type bound to match imported classes against (imported subtypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableTo
ClassesShouldConjunction notBeAssignableTo(java.lang.Class<?> type)
Asserts that classes are not assignable to a certain type. This is the negation ofbeAssignableTo(Class)
.- Parameters:
type
- An upper type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableTo
ClassesShouldConjunction beAssignableTo(java.lang.String typeName)
Asserts that classes are assignable to a certain type with the given type name. This is equivalent tobeAssignableTo(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of an upper type bound to match imported classes against (imported subtypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableTo
ClassesShouldConjunction notBeAssignableTo(java.lang.String typeName)
Asserts that classes are not assignable to a certain type with the given type name. This is equivalent tonotBeAssignableTo(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of an upper type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableTo
ClassesShouldConjunction beAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable to a certain type matching the given predicate. For example, a call withHasName.Predicates.name(String)
would be equivalent tobeAssignableTo(String)
, but the approach is a lot more generic.- Parameters:
predicate
- A predicate identifying an upper type bound to match imported classes against (imported subtypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableTo
ClassesShouldConjunction notBeAssignableTo(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable to a certain type matching the given predicate. This is the negation ofbeAssignableTo(DescribedPredicate)
.- Parameters:
predicate
- A predicate identifying an upper type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableFrom
ClassesShouldConjunction beAssignableFrom(java.lang.Class<?> type)
Asserts that classes are assignable from a certain type (compareClass.isAssignableFrom(Class)
to terminology). This is roughly equivalent to the use of reflection:
A simple example for this predicate would besomeClass.class.isAssignableFrom(type);
assignableFrom(ArrayList.class).apply(importedArrayListClass); // --> returns true assignableFrom(ArrayList.class).apply(importedListClass); // --> returns true assignableFrom(ArrayList.class).apply(importedStringClass); // --> returns false
- Parameters:
type
- A lower type bound to match imported classes against (imported supertypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableFrom
ClassesShouldConjunction notBeAssignableFrom(java.lang.Class<?> type)
Asserts that classes are not assignable from a certain type. This is the negation ofbeAssignableFrom(Class)
.- Parameters:
type
- A lower type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableFrom
ClassesShouldConjunction beAssignableFrom(java.lang.String typeName)
Asserts that classes are assignable from a certain type with the given type name. This is equivalent tobeAssignableFrom(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of a lower type bound to match imported classes against (imported supertypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableFrom
ClassesShouldConjunction notBeAssignableFrom(java.lang.String typeName)
Asserts that classes are not assignable from a certain type with the given type name. This is equivalent tonotBeAssignableFrom(Class)
, but doesn't depend on having a certain type on the classpath.- Parameters:
typeName
- Name of a lower type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAssignableFrom
ClassesShouldConjunction beAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are assignable from a certain type matching the given predicate. For example, a call withHasName.Predicates.name(String)
would be equivalent tobeAssignableFrom(String)
, but the approach is a lot more generic.- Parameters:
predicate
- A predicate identifying a lower type bound to match imported classes against (imported supertypes will match)- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeAssignableFrom
ClassesShouldConjunction notBeAssignableFrom(DescribedPredicate<? super JavaClass> predicate)
Asserts that classes are not assignable from a certain type matching the given predicate. This is the negation ofbeAssignableFrom(DescribedPredicate)
.- Parameters:
predicate
- A predicate identifying a lower type bound imported classes should NOT have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
accessField
ClassesShouldConjunction accessField(java.lang.Class<?> owner, java.lang.String fieldName)
Matches against all accesses (setting or getting) of a specific field.- Parameters:
owner
- The class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
accessField
ClassesShouldConjunction accessField(java.lang.String ownerName, java.lang.String fieldName)
Matches against all accesses (setting or getting) of a specific field.- Parameters:
ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
accessFieldWhere
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.- Parameters:
predicate
- Determines whichJavaFieldAccesses
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
getField
ClassesShouldConjunction getField(java.lang.Class<?> owner, java.lang.String fieldName)
Matches against getting of a specific field (e.g.return someClass.someField;
).- Parameters:
owner
- The class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
getField
ClassesShouldConjunction getField(java.lang.String ownerName, java.lang.String fieldName)
Matches against getting a specific field (e.g.return someClass.someField;
).- Parameters:
ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
getFieldWhere
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.- Parameters:
predicate
- Determines whichJavaFieldAccesses
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
setField
ClassesShouldConjunction setField(java.lang.Class<?> owner, java.lang.String fieldName)
Matches against setting a specific field (e.g.someClass.someField = newValue;
).- Parameters:
owner
- The class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
setField
ClassesShouldConjunction setField(java.lang.String ownerName, java.lang.String fieldName)
Matches against setting a specific field (e.g.someClass.someField = newValue;
).- Parameters:
ownerName
- The fully qualified class name of the class declaring the fieldfieldName
- The name of the field to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
setFieldWhere
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.- Parameters:
predicate
- Determines whichJavaFieldAccesses
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callMethod
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.someClass.call();
).- Parameters:
owner
- Class declaring the methodmethodName
- The method name to match againstparameterTypes
- The parameter types of the respective method- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callMethod
ClassesShouldConjunction callMethod(java.lang.String ownerName, java.lang.String methodName, java.lang.String... parameterTypeNames)
Matches against method call to a specific method (e.g.someClass.call();
).- Parameters:
ownerName
- The fully qualified class name declaring the methodmethodName
- The method name to match againstparameterTypeNames
- The fully qualified parameter type names- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callMethodWhere
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.- Parameters:
predicate
- Determines whichJavaMethodCalls
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callConstructor
ClassesShouldConjunction callConstructor(java.lang.Class<?> owner, java.lang.Class<?>... parameterTypes)
Matches against a constructor call to a specific constructor (e.g.new SomeClass();
).- Parameters:
owner
- Class declaring the constructorparameterTypes
- The parameter types of the respective constructor- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callConstructor
ClassesShouldConjunction callConstructor(java.lang.String ownerName, java.lang.String... parameterTypeNames)
Matches against constructor call to a specific constructor (e.g.new SomeClass();
).- Parameters:
ownerName
- The fully qualified class name declaring the constructorparameterTypeNames
- The fully qualified parameter type names- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callConstructorWhere
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.- Parameters:
predicate
- Determines whichJavaConstructorCalls
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
accessTargetWhere
ClassesShouldConjunction accessTargetWhere(DescribedPredicate<? super JavaAccess<?>> predicate)
Matches against access of arbitrary targets (compareAccessTarget
) where origin (a method or constructor) and target (a field, method or constructor) can be freely restricted by the supplied predicate.- Parameters:
predicate
- Determines whichJavaAccesses
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
callCodeUnitWhere
ClassesShouldConjunction callCodeUnitWhere(DescribedPredicate<? super JavaCall<?>> predicate)
Matches against code unit calls (compareJavaCodeUnit
) where origin (a code unit) and target (a code unit) can be freely restricted by the supplied predicate.- Parameters:
predicate
- Determines whichJavaCalls
match the rule- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
accessClassesThat
ClassesShouldThat accessClassesThat()
Asserts that all classes selected by this rule access certain classes.
NOTE: This usually makes more sense the negated way, e.g.noClasses()
.should()
.accessClassesThat()
.haveFullyQualifiedName(String)
- Returns:
- A syntax element that allows choosing which classes should be accessed
-
accessClassesThat
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.noClasses()
.should()
.accessClassesThat(myPredicate)
- Parameters:
predicate
- Determines whichJavaClasses
match the access target- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
onlyBeAccessed
OnlyBeAccessedSpecification<ClassesShouldConjunction> onlyBeAccessed()
- Returns:
- A syntax element that allows restricting how classes should be accessed
E.g.onlyBeAccessed()
.byAnyPackage(String...)
-
beInterfaces
ClassesShouldConjunction beInterfaces()
Asserts that classes are interfaces.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeInterfaces
ClassesShouldConjunction notBeInterfaces()
Asserts that classes are not interfaces.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
-