public class PropertyInvalidException extends IllegalStateException
Modifier and Type | Field and Description |
---|---|
static String |
PropertyCannotBeEmptyCollection
A message string indicating that a property cannot be an empty collection.
|
static String |
PropertyCannotBeLessThanOne
A message string indicating that a property must be greater than or equal to one.
|
static String |
PropertyCannotBeNaN
A message string indicating that a property cannot be NaN.
|
static String |
PropertyCannotBeNegative
A message string indicating that a property cannot be negative.
|
static String |
PropertyCannotBeNull
A message string indicating that a property cannot be null.
|
static String |
PropertyCannotBePositive
A message string indicating that a property cannot be positive.
|
static String |
PropertyCannotBeZero
A message string indicating that a property may not be set to zero.
|
static String |
PropertyCannotContainNullElements
A message string indicating that a property cannot contain null elements.
|
static String |
PropertyCannotHaveZeroElements
A message string indicating that a property cannot have zero elements.
|
static String |
PropertyMustBeNegative
A message string indicating that a property must be negative.
|
static String |
PropertyMustBePositive
A message string indicating that a property must be positive.
|
static String |
PropertyMustBeSet
A message string indicating that a property must be set prior to execution.
|
Constructor and Description |
---|
PropertyInvalidException(String propertyName,
RuntimeException inner)
Initializes a new instance with a specified property name and a reference to the inner
exception that is the cause of this exception.
|
PropertyInvalidException(String propertyName,
String message)
Initializes a new instance with a specified property name.
|
Modifier and Type | Method and Description |
---|---|
String |
getMessage()
Gets a message that describes the current exception.
|
String |
getPropertyName()
Gets the name of the property that is required.
|
static void |
validateGreaterThanZero(double value,
String propertyName)
Validate that the given property value must be greater than zero, and throw
PropertyInvalidException if it is not. |
static void |
validateGreaterThanZero(double value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be greater than zero, and throw
PropertyInvalidException if it is not. |
static void |
validateGreaterThanZero(int value,
String propertyName)
Validate that the given property value must be greater than zero, and throw
PropertyInvalidException if it is not. |
static void |
validateGreaterThanZero(int value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be greater than zero, and throw
PropertyInvalidException if it is not. |
static <TInterface> |
validateImplementsInterface(TypeLiteral<TInterface> typeLiteralTInterface,
Object value,
String propertyName)
Validate that the given property implements the specified interface.
|
static <TInterface> |
validateImplementsInterface(TypeLiteral<TInterface> typeLiteralTInterface,
Object value,
String propertyName,
String exceptionMessage)
Validate that the given property implements the specified interface.
|
static void |
validateNonNegative(double value,
String propertyName)
Validate that the given property value must be non-negative, and throw
PropertyInvalidException if it is not. |
static void |
validateNonNegative(double value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be non-negative, and throw
PropertyInvalidException if it is not. |
static void |
validateNonNegative(int value,
String propertyName)
Validate that the given property value must be non-negative, and throw
PropertyInvalidException if it is not. |
static void |
validateNonNegative(int value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be non-negative, and throw
PropertyInvalidException if it is not. |
static void |
validateNonNull(Object value,
String propertyName)
Validate that the given property value must be non-null, and throw
PropertyInvalidException if it is not. |
static void |
validateNonNull(Object value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be non-null, and throw
PropertyInvalidException if it is not. |
static void |
validateNonZero(double value,
String propertyName)
Validate that the given property value must be non-zero, and throw
PropertyInvalidException if it is not. |
static void |
validateNonZero(double value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be non-zero, and throw
PropertyInvalidException if it is not. |
static <T> void |
validateNotEmpty(Collection<T> value,
String propertyName)
Validate that the given property value must not be
null or an empty collection, and throw PropertyInvalidException if it is. |
static <T> void |
validateNotEmpty(Collection<T> value,
String propertyName,
String exceptionMessage)
Validate that the given property value must not be
null or an empty collection, and throw PropertyInvalidException if it is. |
static <TKey,TValue> |
validateNotEmpty(Map<TKey,TValue> value,
String propertyName)
Validate that the given property value must not be
null or an empty dictionary, and throw PropertyInvalidException if it is. |
static <TKey,TValue> |
validateNotEmpty(Map<TKey,TValue> value,
String propertyName,
String exceptionMessage)
Validate that the given property value must not be
null or an empty dictionary, and throw PropertyInvalidException if it is. |
static void |
validateNotNaN(double value,
String propertyName)
Validate that the given property value must not be NaN, and throw
PropertyInvalidException if it is. |
static void |
validateNotNaN(double value,
String propertyName,
String exceptionMessage)
Validate that the given property value must not be NaN, and throw
PropertyInvalidException if it is. |
static void |
validateZeroToOne(double value,
String propertyName,
String exceptionMessage)
Validate that the given property value must be between zero and one, and throw
PropertyInvalidException if it is not. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public static final String PropertyCannotBeNull
public static final String PropertyCannotBeNegative
public static final String PropertyMustBePositive
public static final String PropertyCannotBePositive
public static final String PropertyMustBeNegative
public static final String PropertyCannotBeLessThanOne
public static final String PropertyCannotHaveZeroElements
public static final String PropertyCannotContainNullElements
public static final String PropertyMustBeSet
public static final String PropertyCannotBeZero
public static final String PropertyCannotBeNaN
public static final String PropertyCannotBeEmptyCollection
public PropertyInvalidException(String propertyName, String message)
propertyName
- The name of the property that has an invalid value.message
- The message that describes the error.public PropertyInvalidException(String propertyName, RuntimeException inner)
propertyName
- The name of the property that has an invalid value.inner
- The exception that is the cause of the current exception.public final String getPropertyName()
public String getMessage()
getMessage
in class Throwable
public static <TInterface> void validateImplementsInterface(TypeLiteral<TInterface> typeLiteralTInterface, Object value, String propertyName)
TInterface
- The type of interface expected.typeLiteralTInterface
- A TypeLiteral object representing the generic type TInterface
.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
does not implement TInterface
.public static <TInterface> void validateImplementsInterface(TypeLiteral<TInterface> typeLiteralTInterface, Object value, String propertyName, String exceptionMessage)
TInterface
- The type of interface expected.typeLiteralTInterface
- A TypeLiteral object representing the generic type TInterface
.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
does not implement TInterface
.public static void validateNonNull(Object value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is null.public static void validateNonNull(Object value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is null.public static void validateNonZero(double value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is zero.public static void validateNonZero(double value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is zero.public static void validateNonNegative(double value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is less than zero.public static void validateNonNegative(double value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is less than zero.public static void validateNonNegative(int value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is less than zero.public static void validateNonNegative(int value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is less than zero.public static void validateGreaterThanZero(double value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is less than or equal to zero.public static void validateGreaterThanZero(double value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is less than or equal to zero.public static void validateGreaterThanZero(int value, String propertyName)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is less than or equal to zero.public static void validateGreaterThanZero(int value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is less than or equal to zero.public static void validateZeroToOne(double value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is not.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is not between zero and one.public static void validateNotNaN(double value, String propertyName)
PropertyInvalidException
if it is.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is NaN.public static void validateNotNaN(double value, String propertyName, String exceptionMessage)
PropertyInvalidException
if it is.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is NaN.public static <T> void validateNotEmpty(Collection<T> value, String propertyName)
null
or an empty collection, and throw PropertyInvalidException
if it is.T
- The type of items in the collection.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is empty.public static <TKey,TValue> void validateNotEmpty(Map<TKey,TValue> value, String propertyName)
null
or an empty dictionary, and throw PropertyInvalidException
if it is.TKey
- The type of keys in the dictionary.TValue
- The type of values in the dictionary.value
- The property value.propertyName
- The name of the property.PropertyInvalidException
- Thrown if value
is empty.public static <T> void validateNotEmpty(Collection<T> value, String propertyName, String exceptionMessage)
null
or an empty collection, and throw PropertyInvalidException
if it is.T
- The type of items in the collection.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is empty.public static <TKey,TValue> void validateNotEmpty(Map<TKey,TValue> value, String propertyName, String exceptionMessage)
null
or an empty dictionary, and throw PropertyInvalidException
if it is.TKey
- The type of keys in the dictionary.TValue
- The type of values in the dictionary.value
- The property value.propertyName
- The name of the property.exceptionMessage
- The message to use when throwing the exception.PropertyInvalidException
- Thrown if value
is empty.