|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.base.Objects
public class Objects
Utility classes which don't fit anywhere else. Yet.
Method Summary | ||
---|---|---|
static void |
assertNotNull(String name,
Object value)
Checks whether the given value is null and throws an
IllegalArgumentException . |
|
static boolean |
equals(Object o1,
Object o2)
Checks two objects for equality considering whether any of them is null . |
|
static
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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)
value
is null
and throws an
IllegalArgumentException
.
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
values
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |