com.atlassian.velocity.htmlsafe.util
Class Check

java.lang.Object
  extended by com.atlassian.velocity.htmlsafe.util.Check

public final class Check
extends java.lang.Object

Utility to perform checks on parameters.


Constructor Summary
Check()
           
 
Method Summary
static void argument(boolean expression)
          Ensures the truth of an expression involving one or more parameters to the calling method.
static void argument(boolean expression, java.lang.Object errorMessage)
          Ensures the truth of an expression involving one or more parameters to the calling method.
static
<T> T
notNull(T reference)
          Check that reference is not null.
static
<T> T
notNull(T reference, java.lang.Object errorMessage)
          Check that reference is not null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Check

public Check()
Method Detail

notNull

public static <T> T notNull(T reference)
Check that reference is not null. If it is, throw a NullPointerException.

Parameters:
reference - reference to check is null or not
Returns:
reference so it may be used
Throws:
java.lang.NullPointerException - if reference is null

notNull

public static <T> T notNull(T reference,
                            java.lang.Object errorMessage)
Check that reference is not null. If it is, throw a NullPointerException.

Parameters:
reference - reference to check is null or not
errorMessage - message passed to the NullPointerException constructor to give more context when debugging
Returns:
reference so it may be used
Throws:
java.lang.NullPointerException - if reference is null

argument

public static void argument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the calling method.

Parameters:
expression - a boolean expression
Throws:
java.lang.IllegalArgumentException - if expression is false

argument

public static void argument(boolean expression,
                            java.lang.Object errorMessage)
Ensures the truth of an expression involving one or more parameters to the calling method.

Parameters:
expression - a boolean expression
errorMessage - the exception message to use if the check fails; will be converted to a string using String.valueOf(Object)
Throws:
java.lang.IllegalArgumentException - if expression is false


Copyright © 2013 Atlassian. All Rights Reserved.