public class ValidationUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
guardBoundedDouble(double number,
String msg)
Guards number to not be POSITIVE_INFINITY, NEGATIVE_INFINITY, NaN.
|
static void |
guardClosedIntervalDouble(double number,
double min,
double max,
String msg)
Guards double to be in the closed interval.
|
static void |
guardEmpty(String str,
String msg)
Guards string to be empty.
|
static void |
guardEquals(Object obj1,
Object obj2,
String msg)
Guards two object to be equal.
|
static void |
guardFalse(boolean obj,
String msg)
Guards object to be false.
|
static void |
guardGetterExistsForEnum(Class<?> clazz,
Enum<?> enm,
String msg)
Guards given class to have getter for the specified enumeration value.
|
static void |
guardGreaterDouble(double number1,
double number2,
String msg)
Guards number1 to be greater than number2.
|
static void |
guardGreaterOrEqualDouble(double number1,
double number2,
String msg)
Guards number1 to be greater or equal number2.
|
static void |
guardGreaterOrEqualInt(int number1,
int number2,
String msg)
Guards number1 to be greater or equal number2.
|
static void |
guardGreaterOrEqualLong(long number1,
long number2,
String msg)
Guards number1 to be greater or equal number2.
|
static void |
guardIn(Object obj,
Collection<?> allowed,
String msg)
Guards object to be one of the specified values.
|
static void |
guardInstanceOf(Object obj,
Class<?> clazz,
String msg)
Guard object to be instance of the specified class.
|
static void |
guardIpString(String ip,
String msg)
Guards String to be an IP address.
|
static void |
guardMatch(String str,
String regex,
String msg)
Guards string to match the regular expression.
|
static void |
guardNotEmpty(String str,
String msg)
Guards string to be not empty.
|
static <V> void |
guardNotEmptyNullMap(Map<String,V> map,
String msg)
Guards that map has all keys not empty strings and all values are not null.
|
static void |
guardNotEmptyStringInCollection(Collection<String> collection,
String msg)
Guards that collection is not null and also any element inside is not null or empty string.
|
static void |
guardNotNegativeDouble(double number,
String msg)
Guards that specified number is greater or equal to 0.
|
static void |
guardNotNegativeInt(int number,
String msg)
Guards that the specified number is 0, 1, 2...
|
static void |
guardNotNegativeLong(long number,
String msg)
Guards that the specified number is 0, 1, 2...
|
static void |
guardNotNull(Object obj,
String msg)
Guards object to be not null.
|
static <T> void |
guardNotNullCollection(Collection<T> collection,
String msg)
Guards that collection is not null and also any element inside is not null.
|
static <K,V> void |
guardNotNullMap(Map<K,V> map,
String msg)
Guards that map is not null and also all the keys and values are not null.
|
static void |
guardNotZeroInt(int obj,
String msg)
Guards integer to be non zero.
|
static void |
guardNotZeroLong(long obj,
String msg)
Guards long to be one non zero.
|
static void |
guardNull(Object obj,
String msg)
Guards object to be null.
|
static void |
guardPositiveDouble(double number,
String msg)
Guards that specified number is greater then 0.
|
static void |
guardPositiveInt(int number,
String msg)
Guards that specified number is 1, 2, 3...
|
static void |
guardPositiveLong(long number,
String msg)
Guards that specified number is 1, 2, 3...
|
static void |
guardTrue(boolean obj,
String msg)
Guards object to be true.
|
static void |
guardTruncatedDate(Date date,
String msg)
Guards date object to be the date only, without time component.
|
public static void guardTrue(boolean obj,
String msg)
obj - tested objectmsg - message to appear in the exceptionpublic static void guardFalse(boolean obj,
String msg)
obj - tested objectmsg - message to appear in the exceptionpublic static void guardNull(Object obj, String msg)
obj - tested objectmsg - message to appear in the exceptionpublic static void guardNotNull(Object obj, String msg)
obj - tested objectmsg - message to appear in the exceptionpublic static void guardEmpty(String str, String msg)
str - tested stringmsg - message to appear in the exceptionpublic static void guardNotEmpty(String str, String msg)
str - tested stringmsg - message to appear in the exceptionpublic static void guardMatch(String str, String regex, String msg)
str - tested string, not nullregex - regular expression which needs to be satisfiedmsg - name of to put into exception messagepublic static <T> void guardNotNullCollection(Collection<T> collection, String msg)
T - type of the object in the collectioncollection - tested objectmsg - name of to put into exception messagepublic static void guardNotEmptyStringInCollection(Collection<String> collection, String msg)
collection - tested objectmsg - name of to put into exception messagepublic static <K,V> void guardNotNullMap(Map<K,V> map, String msg)
K - key typeV - value typemap - tested objectmsg - massage which appears in exception when validation failedpublic static <V> void guardNotEmptyNullMap(Map<String,V> map, String msg)
V - value typemap - tested objectmsg - massage which appears in exception when validation failedpublic static void guardNotNegativeInt(int number,
String msg)
number - tested numbermsg - message in case of errorpublic static void guardPositiveInt(int number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardPositiveLong(long number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardNotZeroLong(long obj,
String msg)
obj - object to testmsg - message to appear in the exceptionpublic static void guardNotZeroInt(int obj,
String msg)
obj - object to testmsg - message to appear in the exceptionpublic static void guardPositiveDouble(double number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardBoundedDouble(double number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardClosedIntervalDouble(double number,
double min,
double max,
String msg)
number - number to testmin - minimummax - maximummsg - message to appear in the exceptionpublic static void guardNotNegativeLong(long number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardNotNegativeDouble(double number,
String msg)
number - tested numbermsg - message to appear in the exceptionpublic static void guardIpString(String ip, String msg)
ip - tested string to be an IP addressmsg - message to appear in the exceptionpublic static void guardEquals(Object obj1, Object obj2, String msg)
obj1 - object oneobj2 - object twomsg - message to appear in the exceptionpublic static void guardGreaterDouble(double number1,
double number2,
String msg)
number1 - number1 - the one which must be greaternumber2 - number2 - the one which must be lessmsg - message to appear in the exceptionpublic static void guardGreaterOrEqualInt(int number1,
int number2,
String msg)
number1 - number1 - the one which must be greater or equalnumber2 - number2 - the one which must be less or equalmsg - message to appear in the exceptionpublic static void guardGreaterOrEqualLong(long number1,
long number2,
String msg)
number1 - number1 - the one which must be greater or equalnumber2 - number2 - the one which must be less or equalmsg - message to appear in the exceptionpublic static void guardGreaterOrEqualDouble(double number1,
double number2,
String msg)
number1 - number1 - the one which must be greater or equalnumber2 - number2 - the one which must be less or equalmsg - message to appear in the exceptionpublic static void guardInstanceOf(Object obj, Class<?> clazz, String msg)
obj - tested objectclazz - class which is used for the testmsg - message to appear in the exceptionpublic static void guardIn(Object obj, Collection<?> allowed, String msg)
obj - object to testallowed - collection of allowed valuesmsg - message to appear in the exceptionpublic static void guardTruncatedDate(Date date, String msg)
date - date object to be tested as datemsg - message to appear in the exceptionpublic static void guardGetterExistsForEnum(Class<?> clazz, Enum<?> enm, String msg)
clazz - class for which getter should be checkedenm - enumeration valuemsg - message to appear in the exceptionCopyright © 2016. All rights reserved.