Interface AssertFactory<T,ASSERT extends Assert<?,?>>
- Type Parameters:
T- the type of the given value.ASSERT- the type of the resultingAssert.
- All Known Implementing Classes:
InstanceOfAssertFactory,ObjectAssertFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Assert instance for a given value of type AssertFactory.
The createAssert(Object) factory method typically wraps a call to
Assertions.assertThat(java.util.function.Predicate<T>).
More advanced use cases can be achieved via createAssert(ValueProvider),
where the provision of the value is externalized and the factory can require
explicit type compatibility for the value to be provided.
- Since:
- 2.5.0 / 3.5.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA provider that provides a value compatible with a givenType. -
Method Summary
Modifier and TypeMethodDescriptiondefault ASSERTcreateAssert(AssertFactory.ValueProvider<? extends T> valueProvider) Creates the customAssertinstance for the value provided by the givenvalueProvider.createAssert(T actual) Creates the customAssertinstance for the given value.
-
Method Details
-
createAssert
Creates the customAssertinstance for the given value.Typically, this will just invoke
assertThat(actual).- Parameters:
actual- the input value for theAssertinstance- Returns:
- the custom
Assertinstance for the given value
-
createAssert
Creates the customAssertinstance for the value provided by the givenvalueProvider.This is typically used by custom assertions that want to leverage existing factories and need to manipulate the value upfront.
The default implementation always requests a value compatible with
Object.Overriding implementations might provide a more specific
Typeinstance to express the desired type of the value returned by the provider. When doing so, the factory is required to be consistent with the type parameterAssertFactory.- Parameters:
valueProvider- the value provider for theAssertinstance- Returns:
- the custom
Assertinstance for the value provided by the given value provider - Since:
- 3.26.0
-