org.axonframework.common
Class Assert

java.lang.Object
  extended by org.axonframework.common.Assert

public abstract class Assert
extends Object

Utility class (inspired by Springs Assert class) for doing assertions on parameters and object state. To remove the need for explicit dependencies on Spring, the functionality of that class is migrated to this class.

Since:
0.3
Author:
Allard Buijze

Method Summary
static void isFalse(boolean expression, String message)
          Asserts that the given expression is false.
static void isTrue(boolean expression, String message)
          Asserts that the given expression is true.
static void notEmpty(String value, String message)
          Assert that the given value is not null or empty.
static void notNull(Object value, String message)
          Assert that the given value is not null.
static void state(boolean state, String message)
          Asserts that the value of state is true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

state

public static void state(boolean state,
                         String message)
Asserts that the value of state is true. If not, an IllegalStateException is thrown.

Parameters:
state - the state validation expression
message - The message that the exception contains if state evaluates to false

isTrue

public static void isTrue(boolean expression,
                          String message)
Asserts that the given expression is true. If not, an IllegalArgumentException is thrown.

Parameters:
expression - the state validation expression
message - The message that the exception contains if state evaluates to false

isFalse

public static void isFalse(boolean expression,
                           String message)
Asserts that the given expression is false. If not, an IllegalArgumentException is thrown.

Parameters:
expression - the state validation expression
message - The message that the exception contains if state evaluates to true

notNull

public static void notNull(Object value,
                           String message)
Assert that the given value is not null. If not, an IllegalArgumentException is thrown.

Parameters:
value - the value not to be null
message - The message to add to the exception when the assertion fails

notEmpty

public static void notEmpty(String value,
                            String message)
Assert that the given value is not null or empty. If not, an IllegalArgumentException is thrown.

Parameters:
value - the value to contain at least one character
message - The message to add to the exception when the assertion fails


Copyright © 2010-2016. All Rights Reserved.