Package org.assertj.core.api
Class InstanceOfAssertFactory<T,ASSERT extends AbstractAssert<?,?>>
java.lang.Object
org.assertj.core.api.InstanceOfAssertFactory<T,ASSERT>
- Type Parameters:
T
- the type to use for the cast.ASSERT
- the type of the resultingAssert
.
- All Implemented Interfaces:
AssertFactory<Object,
ASSERT>
public class InstanceOfAssertFactory<T,ASSERT extends AbstractAssert<?,?>>
extends Object
implements AssertFactory<Object,ASSERT>
AssertFactory
decorator that casts the input value to the given type before invoking the decorated factory.- Since:
- 3.13.0
- Author:
- Stefano Cordio
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.assertj.core.api.AssertFactory
AssertFactory.ValueProvider<T>
-
Constructor Summary
ConstructorsConstructorDescriptionInstanceOfAssertFactory
(Class<T> rawClass, Type[] typeArguments, AssertFactory<T, ASSERT> delegate) Instantiates a newInstanceOfAssertFactory
for a given type with type arguments.InstanceOfAssertFactory
(Class<T> type, AssertFactory<T, ASSERT> delegate) Instantiates a newInstanceOfAssertFactory
for a given type. -
Method Summary
Modifier and TypeMethodDescriptioncreateAssert
(Object actual) Creates the customAssert
instance for the given value.createAssert
(AssertFactory.ValueProvider<?> valueProvider) Creates the customAssert
instance for the value provided by the givenvalueProvider
.toString()
-
Constructor Details
-
InstanceOfAssertFactory
Instantiates a newInstanceOfAssertFactory
for a given type.- Parameters:
type
- theClass
instance of the given type.delegate
- theAssertFactory
to decorate.
-
InstanceOfAssertFactory
public InstanceOfAssertFactory(Class<T> rawClass, Type[] typeArguments, AssertFactory<T, ASSERT> delegate) Instantiates a newInstanceOfAssertFactory
for a given type with type arguments.- Parameters:
rawClass
- the rawClass
instance of the given type.typeArguments
- theType
arguments of the given type.delegate
- theAssertFactory
to decorate.- Since:
- 3.26.0
-
-
Method Details
-
createAssert
Creates the customAssert
instance for the given value.Before invoking the delegate, the factory casts the value to the raw
Class
defined during instantiation.- Specified by:
createAssert
in interfaceAssertFactory<T,
ASSERT extends AbstractAssert<?, ?>> - Parameters:
actual
- the input value for theAssert
instance- Returns:
- the custom
Assert
instance for the given value
-
createAssert
Creates the customAssert
instance 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.
This implementation requests a value compatible with the
Type
defined during instantiation and casts the provided value to the corresponding rawClass
before invoking the delegate.- Specified by:
createAssert
in interfaceAssertFactory<T,
ASSERT extends AbstractAssert<?, ?>> - Parameters:
valueProvider
- the value provider for theAssert
instance- Returns:
- the custom
Assert
instance for the provided value - Since:
- 3.26.0
-
toString
-