public final class Objects extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> int |
compare(T a,
T b,
Comparator<? super T> c)
Compares two objects with provided comparator.
|
static int |
compareInt(int x,
int y)
Compares two
int values. |
static int |
compareLong(long x,
long y)
Compares two
long values. |
static boolean |
equals(Object a,
Object b)
Checks equality of two objects.
|
static int |
hash(Object... values)
Returns the hash code for objects.
|
static int |
hashCode(Object o)
Returns the hash code of object.
|
static <T> T |
requireNonNull(T obj)
Checks that object reference is not null.
|
static <T> T |
requireNonNull(T obj,
String message)
Checks that object reference is not null.
|
static String |
toString(Object o,
String nullDefault)
Returns result of calling
toString on object or nullDefault if object is null. |
public static boolean equals(Object a, Object b)
a - an objectb - an objecttrue if objects are equals, false otherwisepublic static int hashCode(Object o)
o - an objectpublic static int hash(Object... values)
values - the valuespublic static String toString(Object o, String nullDefault)
toString on object or nullDefault if object is null.o - an objectnullDefault - a string to return if object is nulltoString on object or nullDefault if object is null.public static <T> int compare(T a,
T b,
Comparator<? super T> c)
T - the type of the argumentsa - an objectb - an objectc - the comparatorpublic static int compareInt(int x,
int y)
int values.x - the first int valuey - the second int valuepublic static int compareLong(long x,
long y)
long values.x - the first long valuey - the second long valuepublic static <T> T requireNonNull(T obj)
T - the type of the objectobj - an objectNullPointerException - if object is nullrequireNonNull(java.lang.Object, java.lang.String)public static <T> T requireNonNull(T obj,
String message)
T - the type of the objectobj - an objectmessage - a message to be used as exception detailsNullPointerException - if object is nullrequireNonNull(java.lang.Object)Copyright © 2017. All rights reserved.