Top Description Fields Constructors Methods
org.assertj.core.util

public final Class Objects

extends Object
Class Inheritance
Static Imports
org.assertj.core.util.Arrays.isArray, .Arrays.isNullOrEmpty

Utility methods related to objects.
Authors
Alex Ruiz, Joel Costigliola

Field Summary

Modifier and TypeField and Description
public static final int
HASH_CODE_PRIME

Prime number used to calculate the hash code of objects.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the arguments are deeply equal to each other, false otherwise.
areEqual
(Object
an object.
o1
,
Object
an object to be compared with o1 for deep equality.
o2
)

Returns true if the arguments are deeply equal to each other, false otherwise.
public static boolean

Returns:

true if the arguments are arrays and deeply equal to each other, false otherwise.
areEqualArrays
(Object
an object.
o1
,
Object
an object to be compared with o1 for deep equality.
o2
)

Returns true if the arguments are arrays and deeply equal to each other, false otherwise.
public static <
the generic type to cast the given object to.
T
>
T

Returns:

the casted object, or null if the given object is not to the given type.
castIfBelongsToType
(Object
the object to cast.
o
,
Class<T>
the given type.
type
)

Casts the given object to the given type only if the object is of the given type.

public static int

Returns:

the hash code for the given object
hashCodeFor
(Object
the given object.
o
)

Returns the hash code for the given object.

public static String[]

Returns:

the names of the given types stored in an array.
namesOf
(Class<?>...
the given types.
types
)

Returns an array containing the names of the given types.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HASH_CODE_PRIMEback to summary
public static final int HASH_CODE_PRIME

Prime number used to calculate the hash code of objects.

Constructor Detail

Objectsback to summary
private Objects()

Method Detail

areEqualback to summary
public static boolean areEqual(Object o1, Object o2)

Returns true if the arguments are deeply equal to each other, false otherwise.

Two null values are deeply equal. If both arguments are arrays, the algorithm in java.util.Arrays#deepEquals is used to determine equality. Otherwise, equality is determined by using the Object#equals method of the first argument.

Parameters
o1:Object

an object.

o2:Object

an object to be compared with o1 for deep equality.

Returns:boolean

true if the arguments are deeply equal to each other, false otherwise.

Annotations
@Deprecated
areEqualArraysback to summary
public static boolean areEqualArrays(Object o1, Object o2)

Returns true if the arguments are arrays and deeply equal to each other, false otherwise.

Once verified that the arguments are arrays, the algorithm in java.util.Arrays#deepEquals is used to determine equality.

Parameters
o1:Object

an object.

o2:Object

an object to be compared with o1 for deep equality.

Returns:boolean

true if the arguments are arrays and deeply equal to each other, false otherwise.

Annotations
@Deprecated
castIfBelongsToTypeback to summary
public static <T> T castIfBelongsToType(Object o, Class<T> type)

Casts the given object to the given type only if the object is of the given type. If the object is not of the given type, this method returns null.

Parameters
<T>
the generic type to cast the given object to.
o:Object

the object to cast.

type:Class<T>

the given type.

Returns:T

the casted object, or null if the given object is not to the given type.

hashCodeForback to summary
public static int hashCodeFor(Object o)

Returns the hash code for the given object. If the object is null, this method returns zero. Otherwise calls the method hashCode of the given object.

Parameters
o:Object

the given object.

Returns:int

the hash code for the given object

namesOfback to summary
public static String[] namesOf(Class<?>... types)

Returns an array containing the names of the given types.

Parameters
types:Class<?>[]

the given types.

Returns:String[]

the names of the given types stored in an array.