Interface FieldsShould<CONJUNCTION extends FieldsShouldConjunction>
- All Superinterfaces:
MembersShould<CONJUNCTION>
@PublicAPI(usage=ACCESS)
public interface FieldsShould<CONJUNCTION extends FieldsShouldConjunction>
extends MembersShould<CONJUNCTION>
-
Method Summary
Modifier and TypeMethodDescriptionbeAccessedByMethodsThat(DescribedPredicate<? super JavaMethod> predicate) Asserts that fields are accessed by at least one method matching the given predicate.beFinal()Asserts that fields are final.beStatic()Asserts that fields are static.haveRawType(DescribedPredicate<? super JavaClass> predicate) Asserts that fields have a raw type matching the given predicate.haveRawType(Class<?> type) Asserts that fields have a certain raw type.haveRawType(String typeName) Asserts that fields have a certain fully qualified name of their raw type.notBeAccessedByMethodsThat(DescribedPredicate<? super JavaMethod> predicate) Asserts that fields are not accessed by methods matching the given predicate.Asserts that fields are non-final.Asserts that fields are non-static.notHaveRawType(DescribedPredicate<? super JavaClass> predicate) Asserts that fields do not have a raw type matching the given predicate.notHaveRawType(Class<?> type) Asserts that fields do not have a certain raw type.notHaveRawType(String typeName) Asserts that fields do not have a certain fully qualified name of their raw type.Methods inherited from interface com.tngtech.archunit.lang.syntax.elements.MembersShould
beAnnotatedWith, beAnnotatedWith, beAnnotatedWith, beDeclaredIn, beDeclaredIn, beDeclaredInClassesThat, beDeclaredInClassesThat, beMetaAnnotatedWith, beMetaAnnotatedWith, beMetaAnnotatedWith, bePackagePrivate, bePrivate, beProtected, bePublic, containNumberOfElements, haveFullName, haveFullNameMatching, haveFullNameNotMatching, haveModifier, haveName, haveNameContaining, haveNameEndingWith, haveNameMatching, haveNameNotContaining, haveNameNotEndingWith, haveNameNotMatching, haveNameNotStartingWith, haveNameStartingWith, notBeAnnotatedWith, notBeAnnotatedWith, notBeAnnotatedWith, notBeDeclaredIn, notBeDeclaredIn, notBeMetaAnnotatedWith, notBeMetaAnnotatedWith, notBeMetaAnnotatedWith, notBePackagePrivate, notBePrivate, notBeProtected, notBePublic, notHaveFullName, notHaveModifier, notHaveName
-
Method Details
-
haveRawType
Asserts that fields have a certain raw type.
E.g.
would be violated byfields().should().haveRawType(String.class)someFieldinclass Example { Object someField; }- Parameters:
type- Type fields should have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveRawType
Asserts that fields do not have a certain raw type.
E.g.
would be violated byfields().should().notHaveRawType(String.class)someFieldinclass Example { String someField; }- Parameters:
type- Type fields should not have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveRawType
Asserts that fields have a certain fully qualified name of their raw type.
E.g.
would be violated byfields().should().haveRawType(String.class.getName())someFieldinclass Example { Object someField; }- Parameters:
typeName- Name of type fields should have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveRawType
Asserts that fields do not have a certain fully qualified name of their raw type.
E.g.
would be violated byfields().should().notHaveRawType(String.class.getName())someFieldinclass Example { String someField; }- Parameters:
typeName- Name of type fields should not have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
haveRawType
Asserts that fields have a raw type matching the given predicate.
E.g.
would be violated byfields().should().haveRawType(assignableTo(Serializable.class))someFieldinclass Example { Object someField; }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- A predicate determining which sort of types fields should have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notHaveRawType
@PublicAPI(usage=ACCESS) CONJUNCTION notHaveRawType(DescribedPredicate<? super JavaClass> predicate) Asserts that fields do not have a raw type matching the given predicate.
E.g.
would be violated byfields().should().notHaveRawType(assignableTo(Serializable.class))someFieldinclass Example { String someField; }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- A predicate determining which sort of types fields should not have- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beAccessedByMethodsThat
@PublicAPI(usage=ACCESS) CONJUNCTION beAccessedByMethodsThat(DescribedPredicate<? super JavaMethod> predicate) Asserts that fields are accessed by at least one method matching the given predicate. This mostly makes sense in the negated form
In this form it is equivalent tonoFields().should().beAccessedByMethodsThat(DescribedPredicate)
but might be useful for chaining multiple conditions viaArchRuleDefinition.fields()fields()}.should().notBeAccessedByMethodsThat(DescribedPredicate).FieldsShouldConjunction.andShould()- Parameters:
predicate- A predicate determining the methods this field should not be accessed by- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
- See Also:
-
notBeAccessedByMethodsThat
@PublicAPI(usage=ACCESS) CONJUNCTION notBeAccessedByMethodsThat(DescribedPredicate<? super JavaMethod> predicate) Asserts that fields are not accessed by methods matching the given predicate.- Parameters:
predicate- A predicate determining the methods this field should not be accessed by- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
- See Also:
-
beStatic
Asserts that fields are static.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeStatic
Asserts that fields are non-static.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
beFinal
Asserts that fields are final.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-
notBeFinal
Asserts that fields are non-final.- Returns:
- A syntax element that can either be used as working rule, or to continue specifying a more complex rule
-