public class ValidationUtils extends Object
Constructor and Description |
---|
ValidationUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
assertAllAreNull(String messageIfNull,
Object... objects)
Asserts that all of the objects are null.
|
static int |
assertIsPositive(int num,
String fieldName)
Asserts that the given number is positive (non-negative and non-zero).
|
static <T> T[] |
assertNotEmpty(T[] array,
String fieldName)
Asserts that it is not empty.
|
static <T extends Collection<?>> |
assertNotEmpty(T collection,
String fieldName)
Asserts that it is not empty.
|
static <T> T |
assertNotNull(T object,
String fieldName)
Asserts that the given object is non-null and returns it.
|
static void |
assertParameterNotNull(Object parameterValue,
String errorMessage)
Asserts that the specified parameter value is not
null and
if it is, throws an IllegalArgumentException with the
specified error message. |
static String |
assertStringNotEmpty(String string,
String fieldName)
Asserts that the string is not empty.
|
public static <T> T assertNotNull(T object, String fieldName)
T
- the type of object.object
- Object to assert onfieldName
- Field name to display in exception message if nullpublic static void assertParameterNotNull(Object parameterValue, String errorMessage)
Asserts that the specified parameter value is not null
and
if it is, throws an IllegalArgumentException
with the
specified error message.
parameterValue
- The parameter value being checked.errorMessage
- The error message to include in the
IllegalArgumentException if the specified parameter is null.public static void assertAllAreNull(String messageIfNull, Object... objects)
messageIfNull
- message.objects
- objects.IllegalArgumentException
- if any object provided was NOT null.public static int assertIsPositive(int num, String fieldName)
num
- Number to validatefieldName
- Field name to display in exception message if not
positive.public static <T extends Collection<?>> T assertNotEmpty(T collection, String fieldName)
T
- the collection type.collection
- collection.fieldName
- field name.public static <T> T[] assertNotEmpty(T[] array, String fieldName)
T
- array type.array
- array.fieldName
- field name.Copyright © 2018. All rights reserved.