public final class Objects extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
HASH_CODE_PRIME
Prime number used to calculate the hash code of objects.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(Object o1,
Object o2)
Deprecated.
Use
Objects.deepEquals(Object, Object) instead. |
static boolean |
areEqualArrays(Object o1,
Object o2)
Deprecated.
|
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.
|
static int |
hashCodeFor(Object o)
Returns the hash code for the given object.
|
static String[] |
namesOf(Class<?>... types)
Returns an array containing the names of the given types.
|
public static final int HASH_CODE_PRIME
@Deprecated public static boolean areEqual(Object o1, Object o2)
Objects.deepEquals(Object, Object) instead.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
Arrays.deepEquals(java.lang.Object[], java.lang.Object[]) is used to determine equality.
Otherwise, equality is determined by using the Object.equals(java.lang.Object) method of the first argument.
o1 - an object.o2 - an object to be compared with o1 for deep equality.true if the arguments are deeply equal to each other, false otherwise.@Deprecated public static boolean areEqualArrays(Object o1, Object o2)
Objects.deepEquals(Object, Object) or
Arrays.deepEquals(Object[], Object[]).true if the arguments are arrays and deeply equal to each other, false otherwise.
Once verified that the arguments are arrays, the algorithm in Arrays.deepEquals(java.lang.Object[], java.lang.Object[]) is used
to determine equality.
o1 - an object.o2 - an object to be compared with o1 for deep equality.true if the arguments are arrays and deeply equal to each other, false otherwise.public static String[] namesOf(Class<?>... types)
types - the given types.public static int hashCodeFor(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(Object o, 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.Copyright © 2025. All rights reserved.