com.emarsys.ecommon.util
Class Assertions

java.lang.Object
  extended by com.emarsys.ecommon.util.Assertions

public class Assertions
extends java.lang.Object

Provides assertions which cannot be disabled and do automated logging.

Assertions are used to beware of "this is not possible" conditions, so the throwing of AssertionErrors is done "manually" not using java's assert statement, because they can be turned off and so are not useful at runtime.

It's better to handle AssertionErrors and/or crash early than to leave a program in a "not possible" state which may cause unredoable harm.

Author:
Michael "kULO" Kulovits

Constructor Summary
Assertions()
           
 
Method Summary
static void assertFalse(boolean cond)
           
static void assertFalse(boolean cond, java.lang.String msg)
           
static void assertIsInstanceOf(java.lang.Object o, java.lang.Class<?> clazz)
           
static void assertNotEmpty(java.lang.Object o)
           
static void assertNotNull(java.lang.Object o)
           
static void assertTrue(boolean cond)
           
static void assertTrue(boolean cond, java.lang.String msg)
           
static void fail()
           
static void fail(java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assertions

public Assertions()
Method Detail

assertTrue

public static void assertTrue(boolean cond,
                              java.lang.String msg)
                       throws java.lang.AssertionError
Parameters:
cond -
msg -
Throws:
java.lang.AssertionError

assertFalse

public static void assertFalse(boolean cond,
                               java.lang.String msg)
                        throws java.lang.AssertionError
Parameters:
cond -
msg -
Throws:
java.lang.AssertionError

assertTrue

public static void assertTrue(boolean cond)
                       throws java.lang.AssertionError
Parameters:
cond -
Throws:
java.lang.AssertionError

assertFalse

public static void assertFalse(boolean cond)
                        throws java.lang.AssertionError
Parameters:
cond -
Throws:
java.lang.AssertionError

assertNotNull

public static void assertNotNull(java.lang.Object o)
                          throws java.lang.AssertionError
Parameters:
o -
Throws:
java.lang.AssertionError

assertNotEmpty

public static void assertNotEmpty(java.lang.Object o)
                           throws java.lang.AssertionError
Parameters:
o -
Throws:
java.lang.AssertionError

assertIsInstanceOf

public static void assertIsInstanceOf(java.lang.Object o,
                                      java.lang.Class<?> clazz)
Parameters:
o -
clazz -

fail

public static void fail()
                 throws java.lang.AssertionError
Throws:
java.lang.AssertionError

fail

public static void fail(java.lang.String msg)
                 throws java.lang.AssertionError
Parameters:
msg -
Throws:
java.lang.AssertionError


Copyright © 2010 emarsys AG. All Rights Reserved.