Interface MembersShould<CONJUNCTION extends MembersShouldConjunction<?>>
- All Known Subinterfaces:
CodeUnitsShould<CONJUNCTION>
,FieldsShould<CONJUNCTION>
,MethodsShould<CONJUNCTION>
@PublicAPI(usage=ACCESS)
public interface MembersShould<CONJUNCTION extends MembersShouldConjunction<?>>
-
Method Summary
Modifier and TypeMethodDescriptionbeAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are annotated with an annotation matching the supplied predicate.beAnnotatedWith
(Class<? extends Annotation> annotationType) Asserts that members are annotated with a certain type of annotation.beAnnotatedWith
(String annotationTypeName) Asserts that members are annotated with a certain type of annotation.beDeclaredIn
(Class<?> javaClass) Asserts that members are declared within the supplied class.beDeclaredIn
(String className) Asserts that members are declared within a class of the supplied class name.Allows to assert that members are declared within a certain class.beDeclaredInClassesThat
(DescribedPredicate<? super JavaClass> predicate) Asserts that members are declared within a class matching the supplied predicate.beMetaAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are meta-annotated with an annotation matching the supplied predicate.beMetaAnnotatedWith
(Class<? extends Annotation> annotationType) Asserts that members are meta-annotated with a certain type of annotation.beMetaAnnotatedWith
(String annotationTypeName) Asserts that members are meta-annotated with a certain type of annotation.Asserts that members are package private.Asserts that members are private.Asserts that members are protected.bePublic()
Asserts that members are public.containNumberOfElements
(DescribedPredicate<? super Integer> predicate) Asserts that the number of members checked by this rule conforms to the supplied predicate.haveFullName
(String fullName) Asserts that members have a certain full name (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).haveFullNameMatching
(String regex) Asserts that members have a full name matching a given regular expression (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).haveFullNameNotMatching
(String regex) Asserts that members have a full name not matching a given regular expression (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).haveModifier
(JavaModifier modifier) Asserts that members have a certainJavaModifier
(e.g.Asserts that members have a certain name (i.e.haveNameContaining
(String infix) Asserts that members have a name containing the specified infix.haveNameEndingWith
(String suffix) Asserts that members have a name ending with the specified suffix.haveNameMatching
(String regex) Asserts that members have a name (i.e.haveNameNotContaining
(String infix) Asserts that members have a name not containing the specified infix.haveNameNotEndingWith
(String suffix) Asserts that members have a name not ending with the specified suffix.haveNameNotMatching
(String regex) Asserts that members have a name (i.e.haveNameNotStartingWith
(String prefix) Asserts that members have a name not starting with the specified prefix.haveNameStartingWith
(String prefix) Asserts that members have a name starting with the specified prefix.notBeAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are not annotated with an annotation matching the supplied predicate.notBeAnnotatedWith
(Class<? extends Annotation> annotationType) Asserts that members are not annotated with a certain type of annotation.notBeAnnotatedWith
(String annotationTypeName) Asserts that members are not annotated with a certain type of annotation.notBeDeclaredIn
(Class<?> javaClass) Asserts that members are not declared within the supplied class.notBeDeclaredIn
(String className) Asserts that members are not declared within a class of the supplied class name.notBeMetaAnnotatedWith
(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are not meta-annotated with an annotation matching the supplied predicate.notBeMetaAnnotatedWith
(Class<? extends Annotation> annotationType) Asserts that members are not meta-annotated with a certain type of annotation.notBeMetaAnnotatedWith
(String annotationTypeName) Asserts that members are not meta-annotated with a certain type of annotation.Asserts that members are non-package private.Asserts that members are non-private.Asserts that members are non-protected.Asserts that members are non-public.notHaveFullName
(String fullName) Asserts that members do not have a certain full name (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).notHaveModifier
(JavaModifier modifier) Asserts that members do not have a certainJavaModifier
(e.g.notHaveName
(String name) Asserts that members do not have a certain name (i.e.
-
Method Details
-
haveName
Asserts that members have a certain name (i.e. field name, method name orJavaConstructor.CONSTRUCTOR_NAME
).- Parameters:
name
- The member name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveName
Asserts that members do not have a certain name (i.e. field name, method name orJavaConstructor.CONSTRUCTOR_NAME
).- Parameters:
name
- The member name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameMatching
Asserts that members have a name (i.e. field name, method name orJavaConstructor.CONSTRUCTOR_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
Asserts that members have a name (i.e. field name, method name orJavaConstructor.CONSTRUCTOR_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
-
haveFullName
Asserts that members have a certain full name (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).- Parameters:
fullName
- The member's full name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveFullName
Asserts that members do not have a certain full name (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).- Parameters:
fullName
- The member's full name- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveFullNameMatching
Asserts that members have a full name matching a given regular expression (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).- 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
-
haveFullNameNotMatching
Asserts that members have a full name not matching a given regular expression (compareJavaField.getFullName()
andJavaCodeUnit.getFullName()
).- 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
-
haveNameStartingWith
Asserts that members have a name starting with the specified prefix.- Parameters:
prefix
- A prefix the member name should start with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameNotStartingWith
Asserts that members have a name not starting with the specified prefix.- Parameters:
prefix
- A prefix the member 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
-
haveNameContaining
Asserts that members have a name containing the specified infix.- Parameters:
infix
- An infix the member name should contain- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameNotContaining
Asserts that members have a name not containing the specified infix.- Parameters:
infix
- An infix the member name should not contain- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameEndingWith
Asserts that members have a name ending with the specified suffix.- Parameters:
suffix
- A suffix the member name should end with- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveNameNotEndingWith
Asserts that members have a name not ending with the specified suffix.- Parameters:
suffix
- A suffix the member 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
-
bePublic
Asserts that members are public.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePublic
Asserts that members are non-public.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beProtected
Asserts that members are protected.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeProtected
Asserts that members are non-protected.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
bePackagePrivate
Asserts that members are package private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePackagePrivate
Asserts that members 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
Asserts that members are private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBePrivate
Asserts that members are non-private.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveModifier
Asserts that members 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
Asserts that members do not 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
Asserts that members 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
Asserts that members 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
Asserts that members 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
Asserts that members 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
@PublicAPI(usage=ACCESS) CONJUNCTION beAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are annotated with an annotation matching the supplied predicate.
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaAnnotation
can be found within one of the respective ancestors likeHasType.Predicates
.- 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
@PublicAPI(usage=ACCESS) CONJUNCTION notBeAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are not annotated with an annotation matching the supplied predicate.
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaAnnotation
can be found within one of the respective ancestors likeHasType.Predicates
.- 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
@PublicAPI(usage=ACCESS) CONJUNCTION beMetaAnnotatedWith(Class<? extends Annotation> annotationType) Asserts that members are meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.The assertion is also successful if members are directly annotated with the supplied annotation type.
- 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
@PublicAPI(usage=ACCESS) CONJUNCTION notBeMetaAnnotatedWith(Class<? extends Annotation> annotationType) Asserts that members are not meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.The assertion also fails if members are directly annotated with the supplied annotation type.
- 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
Asserts that members are meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.The assertion is also successful if members are directly annotated with the supplied annotation type.
- 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
Asserts that members are not meta-annotated with a certain type of annotation. A meta-annotation is an annotation that is declared on another annotation.The assertion also fails if members are directly annotated with the supplied annotation type.
- 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
@PublicAPI(usage=ACCESS) CONJUNCTION beMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are meta-annotated with an annotation matching the supplied predicate. A meta-annotation is an annotation that is declared on another annotation.The assertion is also successful if members are directly annotated with an annotation matching the supplied predicate.
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaAnnotation
can be found within one of the respective ancestors likeHasType.Predicates
.- 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
@PublicAPI(usage=ACCESS) CONJUNCTION notBeMetaAnnotatedWith(DescribedPredicate<? super JavaAnnotation<?>> predicate) Asserts that members are not meta-annotated with an annotation matching the supplied predicate. A meta-annotation is an annotation that is declared on another annotation.The assertion also fails if members are directly annotated with an annotation matching the supplied predicate.
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaAnnotation
can be found within one of the respective ancestors likeHasType.Predicates
.- 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
-
beDeclaredIn
Asserts that members are declared within the supplied class.
E.g.
would be violated bymembers()
.should()
.beDeclaredIn(Example.class)
someField
inclass AnyOther { Object someField; }
- Parameters:
javaClass
- A class that members should be declared in- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeDeclaredIn
Asserts that members are not declared within the supplied class.
E.g.
would be violated bymembers()
.should()
.notBeDeclaredIn(Example.class)
someField
inclass Example { Object someField; }
- Parameters:
javaClass
- A class that members should not be declared in- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beDeclaredIn
Asserts that members are declared within a class of the supplied class name.
E.g.
would be violated bymembers()
.should()
.beDeclaredIn(Example.class.getName())
someField
inclass AnyOther { Object someField; }
- Parameters:
className
- Fully qualified name of a class that members should be declared in- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeDeclaredIn
Asserts that members are not declared within a class of the supplied class name.
E.g.
would be violated bymembers()
.should()
.notBeDeclaredIn(Example.class.getName())
someField
inclass Example { Object someField; }
- Parameters:
className
- Fully qualified name of a class that members must not be declared in to match- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beDeclaredInClassesThat
@PublicAPI(usage=ACCESS) CONJUNCTION beDeclaredInClassesThat(DescribedPredicate<? super JavaClass> predicate) Asserts that members are declared within a class matching the supplied predicate.
E.g.
would be violated bymembers()
.should()
.beDeclaredInClassesThat(areSubtypeOf(Example.class))
someField
in
Note that many predefinedclass AnyOther { Object someField; }
predicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- A predicate which matches classes where members have to be declared in- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beDeclaredInClassesThat
Allows to assert that members are declared within a certain class.
E.g.
would be violated bymembers()
.should()
.beDeclaredInClassesThat()
.areAssignableTo(Example.class)
someField
inclass AnyOther { Object someField; }
- Returns:
- A syntax element that allows restricting where members are declared in
-
containNumberOfElements
@PublicAPI(usage=ACCESS) CONJUNCTION containNumberOfElements(DescribedPredicate<? super Integer> predicate) Asserts that the number of members checked by this rule conforms to the supplied predicate.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-