Top Description Inners Fields Constructors Methods
org.assertj.core.api

public Class InstanceOfAssertFactory<T, ASSERT extends AbstractAssert<?, ?>>

extends Object
implements AssertFactory<Object, ASSERT extends AbstractAssert<?, ?>>
Class Inheritance
All Implemented Interfaces
org.assertj.core.api.AssertFactory
Type Parameters
<T>
the type to use for the cast.
<ASSERT>
the type of the resulting Assert.
Static Imports
java.util.Objects.requireNonNull, java.util.stream.Collectors.joining, org.assertj.core.error.ShouldNotBeNull.shouldNotBeNull

AssertFactory decorator that casts the input value to the given type before invoking the decorated factory.
Author
Stefano Cordio
Since
3.13.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final AssertFactory<T, ASSERT>
private final Class<T>
private final Type

Constructor Summary

AccessConstructor and Description
public
InstanceOfAssertFactory(Class<T>
the Class instance of the given type.
type
,
AssertFactory<T, ASSERT>
the AssertFactory to decorate.
delegate
)

Instantiates a new InstanceOfAssertFactory for a given type.

public
InstanceOfAssertFactory(Class<T>
the raw Class instance of the given type.
rawClass
,
Type[]
the Type arguments of the given type.
typeArguments
,
AssertFactory<T, ASSERT>
the AssertFactory to decorate.
delegate
)

Instantiates a new InstanceOfAssertFactory for a given type with type arguments.

private
InstanceOfAssertFactory(Type type, Class<T> rawClass, AssertFactory<T, ASSERT> delegate)

Method Summary

Modifier and TypeMethod and Description
public ASSERT

Returns:

the custom Assert instance for the given value
createAssert
(Object
the input value for the Assert instance
actual
)

Implements org.assertj.core.api.AssertFactory.createAssert.

Creates the custom Assert instance for the given value.
public ASSERT

Returns:

the custom Assert instance for the provided value
createAssert
(AssertFactory.ValueProvider<?>
the value provider for the Assert instance
valueProvider
)

Overrides default org.assertj.core.api.AssertFactory.createAssert.

Implements org.assertj.core.api.AssertFactory.createAssert.

Creates the custom Assert instance for the value provided by the given valueProvider.
pack-priv Class<T>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

delegateback to summary
private final AssertFactory<T, ASSERT> delegate
rawClassback to summary
private final Class<T> rawClass
typeback to summary
private final Type type

Constructor Detail

InstanceOfAssertFactoryback to summary
public InstanceOfAssertFactory(Class<T> type, AssertFactory<T, ASSERT> delegate)

Instantiates a new InstanceOfAssertFactory for a given type.

Parameters
type:Class<T>

the Class instance of the given type.

delegate:AssertFactory<T, ASSERT>

the AssertFactory to decorate.

InstanceOfAssertFactoryback to summary
public InstanceOfAssertFactory(Class<T> rawClass, Type[] typeArguments, AssertFactory<T, ASSERT> delegate)

Instantiates a new InstanceOfAssertFactory for a given type with type arguments.

Parameters
rawClass:Class<T>

the raw Class instance of the given type.

typeArguments:Type[]

the Type arguments of the given type.

delegate:AssertFactory<T, ASSERT>

the AssertFactory to decorate.

Since
3.26.0
InstanceOfAssertFactoryback to summary
private InstanceOfAssertFactory(Type type, Class<T> rawClass, AssertFactory<T, ASSERT> delegate)

Method Detail

createAssertback to summary
public ASSERT createAssert(Object actual)

Implements org.assertj.core.api.AssertFactory.createAssert.

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.

Parameters
actual:Object

the input value for the Assert instance

Returns:ASSERT

the custom Assert instance for the given value

Annotations
@Override
createAssertback to summary
public ASSERT createAssert(AssertFactory.ValueProvider<?> valueProvider)

Overrides default org.assertj.core.api.AssertFactory.createAssert.

Implements org.assertj.core.api.AssertFactory.createAssert.

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.

Parameters
valueProvider:AssertFactory.ValueProvider<?>

the value provider for the Assert instance

Returns:ASSERT

the custom Assert instance for the provided value

Annotations
@Override
Since
3.26.0
getRawClassback to summary
pack-priv Class<T> getRawClass()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
org.assertj.core.api back to summary

private final Class InstanceOfAssertFactory.SyntheticParameterizedType

extends Object
implements ParameterizedType, Serializable
Class Inheritance
  • java.lang.Object
  • org.assertj.core.api.InstanceOfAssertFactory.SyntheticParameterizedType
All Implemented Interfaces
java.io.Serializable, java.lang.reflect.ParameterizedType, java.lang.reflect.Type

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final Type[]

Constructor Summary

AccessConstructor and Description
public
SyntheticParameterizedType(Class<?> rawClass, Type[] typeArguments)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Type[]
getActualTypeArguments()

Implements java.lang.reflect.ParameterizedType.getActualTypeArguments.

Returns an array of Type objects representing the actual type arguments to this type.
public Type
getOwnerType()

Implements java.lang.reflect.ParameterizedType.getOwnerType.

Returns a Type object representing the type that this type is a member of.
public Class<?>
getRawType()

Implements java.lang.reflect.ParameterizedType.getRawType.

Returns the Type object representing the class or interface that declared this type.
public String
getTypeName()

Overrides default java.lang.reflect.Type.getTypeName.

Returns a string describing this type, including information about any type parameters.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

rawClassback to summary
private final Class<?> rawClass
typeArgumentsback to summary
private final Type[] typeArguments

Constructor Detail

SyntheticParameterizedTypeback to summary
public SyntheticParameterizedType(Class<?> rawClass, Type[] typeArguments)

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getActualTypeArgumentsback to summary
public Type[] getActualTypeArguments()

Implements java.lang.reflect.ParameterizedType.getActualTypeArguments.

Doc from java.lang.reflect.ParameterizedType.getActualTypeArguments.

Returns an array of Type objects representing the actual type arguments to this type.

Note that in some cases, the returned array be empty. This can occur if this type represents a non-parameterized type nested within a parameterized type.

Returns:Type[]

an array of Type objects representing the actual type arguments to this type

Annotations
@Override
getOwnerTypeback to summary
public Type getOwnerType()

Implements java.lang.reflect.ParameterizedType.getOwnerType.

Doc from java.lang.reflect.ParameterizedType.getOwnerType.

Returns a Type object representing the type that this type is a member of. For example, if this type is O<T>.I<S>, return a representation of O<T>.

If this type is a top-level type, null is returned.

Returns:Type

a Type object representing the type that this type is a member of. If this type is a top-level type, null is returned

Annotations
@Override
getRawTypeback to summary
public Class<?> getRawType()

Implements java.lang.reflect.ParameterizedType.getRawType.

Doc from java.lang.reflect.ParameterizedType.getRawType.

Returns the Type object representing the class or interface that declared this type.

Returns:Class<?>

the Type object representing the class or interface that declared this type

Annotations
@Override
getTypeNameback to summary
public String getTypeName()

Overrides default java.lang.reflect.Type.getTypeName.

Doc from java.lang.reflect.Type.getTypeName.

Returns a string describing this type, including information about any type parameters.

Returns:String

a string describing this type

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override