final class Validator extends Object
Constructor and Description |
---|
Validator() |
Modifier and Type | Method and Description |
---|---|
(package private) String |
notEmpty(String validated,
String name)
Throws an
NullPointerException if validated string is null or
an IllegalArgumentException if it is empty. |
(package private) int |
notNegative(int validated,
String name)
Validates that the given integer is not negative.
|
(package private) <T> T |
notNull(T validated,
String name)
Throws an
NullPointerException if validated object is null . |
private void |
validateName(String name)
Validates that the given name is not
null or empty. |
<T> T notNull(T validated, String name)
NullPointerException
if validated object is null
.
Sets a proper exception messages which names the parameter which is
null
. Instead of throwing the exception with empty message and
the developer must dig into the stacktrace (if available).
T
- type of validated objectvalidated
- asserted to be not null
name
- of asserted parameter, must not be null
or emptyString notEmpty(String validated, String name)
NullPointerException
if validated string is null
or
an IllegalArgumentException
if it is empty.validated
- asserted to be not null
or emptyname
- of asserted parameter, must not be null
or emptynotNull(java.lang.Object, java.lang.String)
int notNegative(int validated, String name)
Throws an IllegalArgumentException
if given number is less than zero.
validated
- asserted to be not less than 0name
- of asserted parameter, must not be null
or emptyprivate void validateName(String name)
null
or empty.
Throws a NullPointerException
if name is null
or an IllegalArgumentException
if it is empty.
name
- must not be null
or emptyCopyright © 2012 Sven Strittmatter. All Rights Reserved.