public final class Objects
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
HASH_CODE_PRIME
Prime number used to calculate the hash code of objects.
|
Modifier | Constructor and Description |
---|---|
private |
Objects() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
Returns
true if the given objects are equal or if both objects are null . |
static boolean |
areEqualArrays(java.lang.Object o1,
java.lang.Object o2) |
static <T> T |
castIfBelongsToType(java.lang.Object o,
java.lang.Class<T> type)
Casts the given object to the given type only if the object is of the given type.
|
static int |
hashCodeFor(java.lang.Object o)
Returns the hash code for the given object.
|
static java.lang.String[] |
namesOf(java.lang.Class<?>... types)
Returns an array containing the names of the given types.
|
public static final int HASH_CODE_PRIME
public static boolean areEqual(java.lang.Object o1, java.lang.Object o2)
true
if the given objects are equal or if both objects are null
.o1
- one of the objects to compare.o2
- one of the objects to compare.true
if the given objects are equal or if both objects are null
.public static boolean areEqualArrays(java.lang.Object o1, java.lang.Object o2)
public static java.lang.String[] namesOf(java.lang.Class<?>... types)
types
- the given types.public static int hashCodeFor(java.lang.Object o)
null
, this method returns zero. Otherwise
calls the method hashCode
of the given object.o
- the given object.public static <T> T castIfBelongsToType(java.lang.Object o, java.lang.Class<T> type)
null
.T
- the generic type to cast the given object to.o
- the object to cast.type
- the given type.null
if the given object is not to the given type.