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<java.lang.Object,ASSERT>
public class InstanceOfAssertFactory<T,ASSERT extends AbstractAssert<?,?>> extends java.lang.Object implements AssertFactory<java.lang.Object,ASSERT>
AssertFactorydecorator that casts the input value to the given type before invoking the decorated factory.- Since:
- 3.13.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classInstanceOfAssertFactory.SyntheticParameterizedType-
Nested classes/interfaces inherited from interface org.assertj.core.api.AssertFactory
AssertFactory.ValueProvider<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description InstanceOfAssertFactory(java.lang.Class<T> rawClass, java.lang.reflect.Type[] typeArguments, AssertFactory<T,ASSERT> delegate)Instantiates a newInstanceOfAssertFactoryfor a given type with type arguments.InstanceOfAssertFactory(java.lang.Class<T> type, AssertFactory<T,ASSERT> delegate)Instantiates a newInstanceOfAssertFactoryfor a given type.privateInstanceOfAssertFactory(java.lang.reflect.Type type, java.lang.Class<T> rawClass, AssertFactory<T,ASSERT> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ASSERTcreateAssert(java.lang.Object actual)Creates the customAssertinstance for the given value.ASSERTcreateAssert(AssertFactory.ValueProvider<?> valueProvider)Creates the customAssertinstance for the value provided by the givenvalueProvider.(package private) java.lang.Class<T>getRawClass()java.lang.StringtoString()
-
-
-
Field Detail
-
type
private final java.lang.reflect.Type type
-
rawClass
private final java.lang.Class<T> rawClass
-
delegate
private final AssertFactory<T,ASSERT extends AbstractAssert<?,?>> delegate
-
-
Constructor Detail
-
InstanceOfAssertFactory
public InstanceOfAssertFactory(java.lang.Class<T> type, AssertFactory<T,ASSERT> delegate)
Instantiates a newInstanceOfAssertFactoryfor a given type.- Parameters:
type- theClassinstance of the given type.delegate- theAssertFactoryto decorate.
-
InstanceOfAssertFactory
public InstanceOfAssertFactory(java.lang.Class<T> rawClass, java.lang.reflect.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
-
InstanceOfAssertFactory
private InstanceOfAssertFactory(java.lang.reflect.Type type, java.lang.Class<T> rawClass, AssertFactory<T,ASSERT> delegate)
-
-
Method Detail
-
getRawClass
java.lang.Class<T> getRawClass()
-
createAssert
public ASSERT createAssert(java.lang.Object actual)
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
public ASSERT createAssert(AssertFactory.ValueProvider<?> valueProvider)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-