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 resulting Assert.
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
  • Constructor Details Link icon

    • InstanceOfAssertFactory Link icon

      public InstanceOfAssertFactory(Class<T> type, AssertFactory<T,ASSERT> delegate)
      Instantiates a new InstanceOfAssertFactory for a given type.
      Parameters:
      type - the Class instance of the given type.
      delegate - the AssertFactory to decorate.
    • InstanceOfAssertFactory Link icon

      public InstanceOfAssertFactory(Class<T> rawClass, Type[] typeArguments, AssertFactory<T,ASSERT> delegate)
      Instantiates a new InstanceOfAssertFactory for a given type with type arguments.
      Parameters:
      rawClass - the raw Class instance of the given type.
      typeArguments - the Type arguments of the given type.
      delegate - the AssertFactory to decorate.
      Since:
      3.26.0
  • Method Details Link icon

    • createAssert Link icon

      public ASSERT createAssert(Object actual)
      Creates the custom Assert 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 interface AssertFactory<T,ASSERT extends AbstractAssert<?,?>>
      Parameters:
      actual - the input value for the Assert instance
      Returns:
      the custom Assert instance for the given value
    • createAssert Link icon

      public ASSERT createAssert(AssertFactory.ValueProvider<?> valueProvider)
      Creates the custom Assert instance for the value provided by the given valueProvider.

      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 raw Class before invoking the delegate.

      Specified by:
      createAssert in interface AssertFactory<T,ASSERT extends AbstractAssert<?,?>>
      Parameters:
      valueProvider - the value provider for the Assert instance
      Returns:
      the custom Assert instance for the provided value
      Since:
      3.26.0
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object