Enum Class RecursiveAssertionConfiguration.OptionalAssertionPolicy
java.lang.Object
java.lang.Enum<RecursiveAssertionConfiguration.OptionalAssertionPolicy>
org.assertj.core.api.recursive.assertion.RecursiveAssertionConfiguration.OptionalAssertionPolicy
- All Implemented Interfaces:
Serializable
,Comparable<RecursiveAssertionConfiguration.OptionalAssertionPolicy>
,Constable
- Enclosing class:
RecursiveAssertionConfiguration
public static enum RecursiveAssertionConfiguration.OptionalAssertionPolicy
extends Enum<RecursiveAssertionConfiguration.OptionalAssertionPolicy>
Possible policies to use regarding optionals when recursively asserting over the fields of an object tree.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this class with the specified name.values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
OPTIONAL_VALUE_ONLY
Apply thePredicate
(recursively) to the value of the optional field but not the optional field.Consider the following example:
With this policy,class Parent { Optional<String> greeting = Optional.of("Hi"); } Parent parent = new Parent(); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to the optional value "Hi" but not to thegreeting
Optional field. -
OPTIONAL_OBJECT_ONLY
Apply thePredicate
to the optional field but not to its value.Consider the following example:
With this policy,class Parent { Optional<String> greeting = Optional.of("Hi"); } Parent parent = new Parent(); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreeting
Optional field but not to the optional value "Hi". -
OPTIONAL_OBJECT_AND_VALUE
public static final RecursiveAssertionConfiguration.OptionalAssertionPolicy OPTIONAL_OBJECT_AND_VALUEApply thePredicate
to the optional field as well as to (recursively) its value.Consider the following example:
With this policy,class Parent { List<String> greetings = new Optional<>(); } Parent parent = new Parent(); parent.greetings.add("Hello"); parent.greetings.add("Salut"); assertThat(parent).usingRecursiveAssertion() .allFieldsSatisfy(field -> myPredicate(field));
myPredicate(field)
is applied to thegreeting
Optional field and its value "Hi".
-
-
Constructor Details
-
OptionalAssertionPolicy
private OptionalAssertionPolicy()
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-