Android APIs
public final class

Objects

extends Object
java.lang.Object
   ↳ java.util.Objects

Class Overview

Utility methods for objects.

Summary

Public Methods
static <T> int compare(T a, T b, Comparator<? super T> c)
Returns 0 if a == b, or c.compare(a, b) otherwise.
static boolean deepEquals(Object a, Object b)
Returns true if both arguments are null, the result of equals(boolean[], boolean[]) if both arguments are primitive arrays, the result of deepEquals(Object[], Object[]) if both arguments are arrays of reference types, and the result of equals(Object) otherwise.
static boolean equals(Object a, Object b)
Null-safe equivalent of a.equals(b).
static int hash(Object... values)
Convenience wrapper for hashCode(), adding varargs.
static int hashCode(Object o)
Returns 0 for null or o.hashCode().
static <T> T requireNonNull(T o, String message)
Returns o if non-null, or throws NullPointerException with the given detail message.
static <T> T requireNonNull(T o)
Returns o if non-null, or throws NullPointerException.
static String toString(Object o, String nullString)
Returns nullString for null or o.toString().
static String toString(Object o)
Returns "null" for null or o.toString().
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static int compare (T a, T b, Comparator<? super T> c)

Added in API level 19

Returns 0 if a == b, or c.compare(a, b) otherwise. That is, this makes c null-safe.

public static boolean deepEquals (Object a, Object b)

Added in API level 19

Returns true if both arguments are null, the result of equals(boolean[], boolean[]) if both arguments are primitive arrays, the result of deepEquals(Object[], Object[]) if both arguments are arrays of reference types, and the result of equals(Object) otherwise.

public static boolean equals (Object a, Object b)

Added in API level 19

Null-safe equivalent of a.equals(b).

public static int hash (Object... values)

Added in API level 19

Convenience wrapper for hashCode(), adding varargs. This can be used to compute a hash code for an object's fields as follows: Objects.hash(a, b, c).

public static int hashCode (Object o)

Added in API level 19

Returns 0 for null or o.hashCode().

public static T requireNonNull (T o, String message)

Added in API level 19

Returns o if non-null, or throws NullPointerException with the given detail message.

public static T requireNonNull (T o)

Added in API level 19

Returns o if non-null, or throws NullPointerException.

public static String toString (Object o, String nullString)

Added in API level 19

Returns nullString for null or o.toString().

public static String toString (Object o)

Added in API level 19

Returns "null" for null or o.toString().