|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jplate.foundation.util.Assert
public final class Assert
Provides validatation functionality through the concept of assertions: object not null, references not equal, non-empty string, etc.
The following are examples to perform assertions:Assert.notNull ( "foo == null", foo );If
foo
is null, a NullPointerException
is raised and the message will be "foo == null
."
Assert.referenceNotEqual ( "foo == bar", foo, bar );If
foo
and bar
refer to the same object, an
IllegalArgumentException
is
and the message will be "foo == bar
."
Assert.notEmptyString ( "fooStr is empty", fooStr );If
fooStr
is either null or the empty string (""), an
IllegalArgumentException
is and the message will be
"fooStr is empty
."
Modifications: $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $ $Revision: 479 $ $Author: sfloess $ $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/util/Assert.java $
Constructor Summary | |
---|---|
private |
Assert()
Default constructor not allowed. |
Method Summary | |
---|---|
static void |
isOfClass(java.lang.Object toCheck,
java.lang.Class klass)
Ensures that toCheck is of class type klass . |
static void |
isOfClass(java.lang.String msg,
java.lang.Object toCheck,
java.lang.Class klass)
Ensures that toCheck is of class type klass . |
static void |
isReferenced(java.lang.Object toCheck)
Ensures that toCheck is referencing something other than null. |
static void |
isReferenced(java.lang.String msg,
java.lang.Object toCheck)
Ensures that toCheck is referencing something other than null. |
static void |
notEmptyString(java.lang.String toCheck)
Ensures that toCheck is not empty or null. |
static void |
notEmptyString(java.lang.String msg,
java.lang.String toCheck)
Ensures that toCheck is not empty or null. |
static void |
notNull(java.lang.Object toCheck)
Ensures that toCheck is not null. |
static void |
notNull(java.lang.String msg,
java.lang.Object toCheck)
Ensures that toCheck is not null. |
static void |
referenceNotEqual(java.lang.Object value1,
java.lang.Object value2)
Ensures that value1 and value2 are not equal. |
static void |
referenceNotEqual(java.lang.String msg,
java.lang.Object value1,
java.lang.Object value2)
Ensures that value1 and value2 are not equal. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private Assert()
java.lang.UnsupportedOperationException
- if this constructor is called.Method Detail |
---|
public static void notNull(java.lang.String msg, java.lang.Object toCheck) throws java.lang.NullPointerException
toCheck
is not null. If it is, a
NullPointerException
is raised whose message is
msg
.
msg
- The message to use in NullPointerException
if toCheck
is null.toCheck
- The object to check for null.
java.lang.NullPointerException
- If toCheck
is null.public static void notNull(java.lang.Object toCheck) throws java.lang.NullPointerException
toCheck
is not null. If it is, a
NullPointerException
is raised.
toCheck
- The object to check for null.
java.lang.NullPointerException
- If toCheck
is null.public static void isReferenced(java.lang.String msg, java.lang.Object toCheck) throws java.lang.IllegalArgumentException
toCheck
is referencing something other than null.
If it is, a IllegalArgumentException
is raised.
msg
- The message to use in
IllegalArgumentException
if
toCheck
is null.toCheck
- The object to check for being a reference and not null.
java.lang.IllegalArgumentException
- If toCheck
is null.public static void isReferenced(java.lang.Object toCheck) throws java.lang.IllegalArgumentException
toCheck
is referencing something other than null.
If it is, a IllegalArgumentException
is raised.
toCheck
- The object to check for being a reference and not null.
java.lang.IllegalArgumentException
- If toCheck
is null.public static void isOfClass(java.lang.String msg, java.lang.Object toCheck, java.lang.Class klass) throws java.lang.IllegalArgumentException
toCheck
is of class type klass
. If
not, an IllegalArgumentException
is raised.
msg
- The message to use in
IllegalArgumentException
if
toCheck
is not of class klass
.toCheck
- The object to check for being of class type
klass
.klass
- The class that toCheck
should be.
java.lang.IllegalArgumentException
- If toCheck
's class is not
klass
.public static void isOfClass(java.lang.Object toCheck, java.lang.Class klass) throws java.lang.IllegalArgumentException
toCheck
is of class type klass
. If
not, an IllegalArgumentException
is raised.
toCheck
- The object to check for being of class type
klass
.klass
- The class that toCheck
should be.
java.lang.IllegalArgumentException
- If toCheck
's class is not
klass
.public static void referenceNotEqual(java.lang.String msg, java.lang.Object value1, java.lang.Object value2) throws java.lang.IllegalArgumentException
value1
and value2
are not equal. If
so, an IllegalArgumentException
is raised whose message is
msg
.
msg
- The message to use in IllegalArgumentException
if toCheck
is null.value1
- The object to examine to ensure not equal to
value2
.
java.lang.IllegalArgumentException
- if toCheck
is null.public static void referenceNotEqual(java.lang.Object value1, java.lang.Object value2) throws java.lang.IllegalArgumentException
value1
and value2
are not equal. If
so, an IllegalArgumentException
.
value1
- The object to examine to ensure not equal to
value2
.
java.lang.IllegalArgumentException
- if toCheck
is null.public static void notEmptyString(java.lang.String msg, java.lang.String toCheck) throws java.lang.IllegalArgumentException
toCheck
is not empty or null. If it is, an
IllegalArgumentException
is raised whose message is
msg
.
msg
- The message to use in
IllegalArgumentException
if
toCheck
is null or empty.toCheck
- The string check for null or empty.
java.lang.IllegalArgumentException
- if toCheck is null or empty.public static void notEmptyString(java.lang.String toCheck) throws java.lang.IllegalArgumentException
toCheck
is not empty or null. If it is, an
IllegalArgumentException
is raised.
toCheck
- The string check for null or empty.
java.lang.IllegalArgumentException
- if toCheck is null or empty.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |