Methods Summary |
---|
public static int | compare(T a, T b, java.util.Comparator c)Returns 0 if {@code a == b}, or {@code c.compare(a, b)} otherwise.
That is, this makes {@code c} null-safe.
if (a == b) {
return 0;
}
return c.compare(a, b);
|
public static boolean | deepEquals(java.lang.Object a, java.lang.Object b)Returns true if both arguments are null,
the result of {@link Arrays#equals} if both arguments are primitive arrays,
the result of {@link Arrays#deepEquals} if both arguments are arrays of reference types,
and the result of {@link #equals} otherwise.
if (a == null || b == null) {
return a == b;
} else if (a instanceof Object[] && b instanceof Object[]) {
return Arrays.deepEquals((Object[]) a, (Object[]) b);
} else if (a instanceof boolean[] && b instanceof boolean[]) {
return Arrays.equals((boolean[]) a, (boolean[]) b);
} else if (a instanceof byte[] && b instanceof byte[]) {
return Arrays.equals((byte[]) a, (byte[]) b);
} else if (a instanceof char[] && b instanceof char[]) {
return Arrays.equals((char[]) a, (char[]) b);
} else if (a instanceof double[] && b instanceof double[]) {
return Arrays.equals((double[]) a, (double[]) b);
} else if (a instanceof float[] && b instanceof float[]) {
return Arrays.equals((float[]) a, (float[]) b);
} else if (a instanceof int[] && b instanceof int[]) {
return Arrays.equals((int[]) a, (int[]) b);
} else if (a instanceof long[] && b instanceof long[]) {
return Arrays.equals((long[]) a, (long[]) b);
} else if (a instanceof short[] && b instanceof short[]) {
return Arrays.equals((short[]) a, (short[]) b);
}
return a.equals(b);
|
public static boolean | equals(java.lang.Object a, java.lang.Object b)Null-safe equivalent of {@code a.equals(b)}.
return (a == null) ? (b == null) : a.equals(b);
|
public static int | hash(java.lang.Object values)Convenience wrapper for {@link Arrays#hashCode}, adding varargs.
This can be used to compute a hash code for an object's fields as follows:
{@code Objects.hash(a, b, c)}.
return Arrays.hashCode(values);
|
public static int | hashCode(java.lang.Object o)Returns 0 for null or {@code o.hashCode()}.
return (o == null) ? 0 : o.hashCode();
|
public static T | requireNonNull(T o)Returns {@code o} if non-null, or throws {@code NullPointerException}.
if (o == null) {
throw new NullPointerException();
}
return o;
|
public static T | requireNonNull(T o, java.lang.String message)Returns {@code o} if non-null, or throws {@code NullPointerException}
with the given detail message.
if (o == null) {
throw new NullPointerException(message);
}
return o;
|
public static java.lang.String | toString(java.lang.Object o, java.lang.String nullString)Returns {@code nullString} for null or {@code o.toString()}.
return (o == null) ? nullString : o.toString();
|
public static java.lang.String | toString(java.lang.Object o)Returns "null" for null or {@code o.toString()}.
return (o == null) ? "null" : o.toString();
|