org.ehcache.internal.classes.commonslang
Class Validate

java.lang.Object
  extended by org.ehcache.internal.classes.commonslang.Validate

public class Validate
extends java.lang.Object

This class assists in validating arguments. The validation methods are based along the following principles:

All exceptions messages are format strings as defined by the Java platform. For example:

 Validate.isTrue(i > 0, "The value must be greater than zero: %d", i);
 Validate.notNull(surname, "The surname must not be %s", null);
 

#ThreadSafe#

Since:
2.0
See Also:
String.format(String, Object...)

Constructor Summary
Validate()
          Constructor.
 
Method Summary
static
<T> T
notNull(T object, java.lang.String message, java.lang.Object... values)
          Validate that the specified argument is not null; otherwise throwing an exception with the specified message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validate

public Validate()
Constructor. This class should not normally be instantiated.

Method Detail

notNull

public static <T> T notNull(T object,
                            java.lang.String message,
                            java.lang.Object... values)

Validate that the specified argument is not null; otherwise throwing an exception with the specified message.

Validate.notNull(myObject, "The object must not be null");

Type Parameters:
T - the object type
Parameters:
object - the object to check
message - the String.format(String, Object...) exception message if invalid, not null
values - the optional values for the formatted exception message
Returns:
the validated object (never null for method chaining)
Throws:
java.lang.NullPointerException - if the object is null
See Also:
#notNull(Object)