public final class Objects extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
Objects.HashCodeBuilder |
A builder to simplify the building of hash codes.
|
static class |
Objects.ToStringBuilder |
A builder to build a default
Object#toString() value. |
Modifier and Type | Method | Description |
---|---|---|
static boolean |
areEqual(boolean first,
boolean second) |
Checks to see if two booleans are equal.
|
static boolean |
areEqual(char first,
char second) |
Checks to see if two characters are equal.
|
static boolean |
areEqual(double first,
double second) |
Checks to see if two doubles are equal.
|
static boolean |
areEqual(float first,
float second) |
Checks to see if two floats are equal.
|
static boolean |
areEqual(long first,
long second) |
Checks to see if two longs are equal.
|
static boolean |
areEqual(Object first,
Object second) |
Checks to see if two objects are equal.
|
static <T> T |
checkNonNull(T ref) |
Checks to see if an object is
null , otherwise throws an
IllegalArgumentException . |
static <T> T |
checkNonNull(T ref,
String message) |
Checks to see if an object is
null , otherwise throws an
IllegalArgumentException . |
static <T> T |
checkNonNull(T ref,
String message,
Object... args) |
Checks to see if an object is
null , otherwise throws an
IllegalArgumentException . |
public static boolean areEqual(boolean first, boolean second)
first
- the first boolean.second
- the second boolean.true
if the first is equal to the second, otherwise
false
.public static boolean areEqual(char first, char second)
first
- the first character.second
- the second character.true
if the first is equal to the second, otherwise
false
.public static boolean areEqual(long first, long second)
first
- the first long.second
- the second long.true
if the first is equal to the second, otherwise
false
.public static boolean areEqual(float first, float second)
first
- the first float.second
- the second float.true
if the first is equal to the second, otherwise
false
.public static boolean areEqual(double first, double second)
first
- the first double.second
- the second double.true
if the first is equal to the second, otherwise
false
.public static boolean areEqual(Object first, Object second)
Note this method does not handle arrays. The Arrays
class has utilities for equality of arrays.
first
- the first optionally null
object.second
- the second optionally null
object.true
if the first is equal to the second, otherwise
false
.public static <T> T checkNonNull(T ref)
null
, otherwise throws an
IllegalArgumentException
.T
- the type of the object.ref
- the reference to the object.null
.public static <T> T checkNonNull(T ref, String message)
null
, otherwise throws an
IllegalArgumentException
.T
- the type of the object.ref
- the reference to the object.message
- the message used in the IllegalArgumentException
constructor.null
.public static <T> T checkNonNull(T ref, String message, Object... args)
null
, otherwise throws an
IllegalArgumentException
.T
- the type of the object.ref
- the reference to the object.message
- the message format used in the
IllegalArgumentException
constructor.args
- the arguments used to format the message.null
.Copyright © 2018. All rights reserved.