public class Objects extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertNotNull(String name,
Object value)
|
static boolean |
equals(Object o1,
Object o2)
Checks two objects for equality considering whether any of them is
null . |
static <T> T |
requireNotNull(String name,
T object)
If given
object is null a IllegalArgumentException will be thrown;
otherwise the object itself is returned. |
static String |
toString(Object value,
String nullDefault)
If the value is non-
null , return the value's Object.toString() result. |
public static final boolean equals(Object o1, Object o2)
null
.o1
- o2
- true
if both objects are null
or both are non-
null
and o1.equals(o1) returned truepublic static void assertNotNull(String name, Object value)
name
- the argument name. Used to enrich the exception messagevalue
- the value to be checkedpublic static <T> T requireNotNull(String name, T object)
object
is null
a IllegalArgumentException
will be thrown;
otherwise the object
itself is returned.
If name
is null
the method will use the placeholder
<unknown argument name>
instead.
T
- Simply ensures type symmetry.name
- Identifies object
argument. Used to build an error message if an
IllegalArgumentException
is thrown. May be null
.object
- The subject to test for nullity
.object
passed through if not null
.IllegalArgumentException
- If object
was null
.public static String toString(Object value, String nullDefault)
null
, return the value's Object.toString()
result. Return
the given default otherwise.value
- the valuenullDefault
- the default for null
valuesCopyright © 2024 levigo holding gmbh. All rights reserved.