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 newInstanceOfAssertFactoryfor a given type with type arguments.InstanceOfAssertFactory(Class<T> type, AssertFactory<T, ASSERT> delegate) Instantiates a newInstanceOfAssertFactoryfor a given type. -
Method Summary
Modifier and TypeMethodDescriptioncreateAssert(Object actual) Creates the customAssertinstance for the given value.createAssert(AssertFactory.ValueProvider<?> valueProvider) Creates the customAssertinstance for the value provided by the givenvalueProvider.toString()
-
Constructor Details
-
InstanceOfAssertFactory
Instantiates a newInstanceOfAssertFactoryfor a given type.- Parameters:
type- theClassinstance of the given type.delegate- theAssertFactoryto decorate.
-
InstanceOfAssertFactory
public InstanceOfAssertFactory(Class<T> rawClass, Type[] typeArguments, AssertFactory<T, ASSERT> delegate) Instantiates a newInstanceOfAssertFactoryfor a given type with type arguments.- Parameters:
rawClass- the rawClassinstance of the given type.typeArguments- theTypearguments of the given type.delegate- theAssertFactoryto decorate.- Since:
- 3.26.0
-
-
Method Details
-
createAssert
Creates the customAssertinstance for the given value.Before invoking the delegate, the factory casts the value to the raw
Classdefined during instantiation.- Specified by:
createAssertin interfaceAssertFactory<T,ASSERT extends AbstractAssert<?, ?>> - 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.
This implementation requests a value compatible with the
Typedefined during instantiation and casts the provided value to the corresponding rawClassbefore invoking the delegate.- Specified by:
createAssertin interfaceAssertFactory<T,ASSERT extends AbstractAssert<?, ?>> - Parameters:
valueProvider- the value provider for theAssertinstance- Returns:
- the custom
Assertinstance for the provided value - Since:
- 3.26.0
-
toString
-