|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.eos.util.Conditions
public final class Conditions
Provides static methods to simpler condition handling. This implies less code.
Example
if (reference == null) { throw new IllegalArgumentException("reference is null"); } this.value = reference;
will change to a simple single line:
this.value = checkArgumentNotNull(reference, "reference is null");
Method Summary | ||
---|---|---|
static void |
checkArgument(boolean expr)
Checks the expression of an argument and throws an IllegalArgumentException if the expression is false . |
|
static void |
checkArgument(boolean expr,
Object errorMessage)
Checks the expression of an argument and throws an IllegalArgumentException if the expression is false . |
|
static
|
checkArgumentNotNull(T ref)
Checks that the given reference is null and throws an
IllegalArgumentException if so. |
|
static
|
checkArgumentNotNull(T ref,
Object errorMessage)
Checks that the given reference is null and throws an
IllegalArgumentException if so. |
|
static void |
checkState(boolean expr)
Checks the expression of an argument and throws an IllegalStateException if the expression is false . |
|
static void |
checkState(boolean expr,
Object errorMessage)
Checks the expression of an argument and throws an IllegalStateException if the expression is false . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T checkArgumentNotNull(T ref)
null
and throws an
IllegalArgumentException
if so.
ref
- an object reference
null
reference
IllegalArgumentException
- if ref
is null
public static <T> T checkArgumentNotNull(T ref, Object errorMessage)
null
and throws an
IllegalArgumentException
if so.
ref
- an object reference
null
reference
IllegalArgumentException
- if ref
is null
public static void checkArgument(boolean expr)
IllegalArgumentException
if the expression is false
.
expr
- the expression to test
IllegalArgumentException
- if expr
is false
public static void checkArgument(boolean expr, Object errorMessage)
IllegalArgumentException
if the expression is false
.
expr
- the expression to test
IllegalArgumentException
- if expr
is false
public static void checkState(boolean expr)
IllegalStateException
if the expression is false
.
expr
- the expression to test
IllegalStateException
- if expr
is false
public static void checkState(boolean expr, Object errorMessage)
IllegalStateException
if the expression is false
.
expr
- the expression to test
IllegalStateException
- if expr
is false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |