public class NullArgumentException extends IllegalArgumentException
public Person( String name, int age )
{
NullArgumentException.validateNotEmpty( name, "name" )
if( age > 120 )
throw new IllegalArgumentException( "age > 120" );
if( age < 0 )
throw new IllegalArgumentException( "age < 0" );
}
Constructor and Description |
---|
NullArgumentException(String msg)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
validateNotEmpty(Object[] arrayToCheck,
String argumentName)
Validates that the array instance is not null and that it has entries.
|
static void |
validateNotEmpty(Properties propertiesToCheck,
String argumentName)
Validates that the Properties instance is not null and that it has entries.
|
static void |
validateNotEmpty(String stringToCheck,
boolean trim,
String argumentName)
Validates that the string is not null and not an empty string.
|
static void |
validateNotEmpty(String stringToCheck,
String argumentName)
Validates that the string is not null and not an empty string without trimming the string.
|
static void |
validateNotEmptyContent(String[] arrayToCheck,
boolean trim,
String argumentName)
Validates that the string array instance is not null and that it has entries that are not null or empty.
|
static void |
validateNotEmptyContent(String[] arrayToCheck,
String argumentName)
Validates that the string array instance is not null and that it has entries that are not null or empty
eithout trimming the string.
|
static void |
validateNotNull(Object obj,
String objectName)
Validates that the object
obj is not null. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public NullArgumentException(String msg)
msg
- The message to use in the exception describing the problem.public static void validateNotNull(Object obj, String objectName) throws NullArgumentException
obj
is not null.obj
- The object to be tested.objectName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the stringToCheck is either null or zero characters long.public static void validateNotEmpty(String stringToCheck, String argumentName) throws NullArgumentException
stringToCheck
- The object to be tested.argumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the stringToCheck is either null or zero characters long.public static void validateNotEmpty(String stringToCheck, boolean trim, String argumentName) throws NullArgumentException
stringToCheck
- The object to be tested.trim
- If the elements should be trimmed before checking if emptyargumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the stringToCheck is either null or zero characters long.public static void validateNotEmpty(Properties propertiesToCheck, String argumentName) throws NullArgumentException
propertiesToCheck
- The object to be tested.argumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the Properties instance is null or does not have any entries.public static void validateNotEmpty(Object[] arrayToCheck, String argumentName) throws NullArgumentException
arrayToCheck
- The object to be tested.argumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the array instance is null or does not have any entries.public static void validateNotEmptyContent(String[] arrayToCheck, String argumentName) throws NullArgumentException
arrayToCheck
- The object to be tested.argumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the array instance is null or does not have any entries.public static void validateNotEmptyContent(String[] arrayToCheck, boolean trim, String argumentName) throws NullArgumentException
arrayToCheck
- The object to be tested.trim
- If the elements should be trimmed before checking if emptyargumentName
- The name of the object, which is used to construct the exception message.NullArgumentException
- if the array instance is null or does not have any entries.Copyright © 2011–2016 Red Hat. All rights reserved.