com.levigo.util.base
Class Objects

java.lang.Object
  extended by com.levigo.util.base.Objects

public class Objects
extends Object

Utility classes which don't fit anywhere else. Yet.

Author:
hennejg

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
<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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equals

public static final boolean equals(Object o1,
                                   Object o2)
Checks two objects for equality considering whether any of them is null.

Parameters:
o1 -
o2 -
Returns:
true if both objects are null or both are non- null and o1.equals(o1) returned true

assertNotNull

public static void assertNotNull(String name,
                                 Object value)
Checks whether the given value is null and throws an IllegalArgumentException.

Parameters:
name - the argument name. Used to enrich the exception message
value - the value to be checked

requireNotNull

public static <T> T requireNotNull(String name,
                                   T object)
If given 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.

Type Parameters:
T - Simply ensures type symmetry.
Parameters:
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.
Returns:
The same object passed through if not null.
Throws:
IllegalArgumentException - If object was null.

toString

public static String toString(Object value,
                              String nullDefault)
If the value is non-null, return the value's Object.toString() result. Return the given default otherwise.

Parameters:
value - the value
nullDefault - the default for null values
Returns:


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.