public class ValidationUtils
extends java.lang.Object
| Constructor and Description |
|---|
ValidationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNonEmpty(java.util.Collection<?> collection)
Checks that a
Collection is not null and that it is not empty. |
static java.lang.String |
nonEmpty(java.lang.String string)
Checks that a
String is not null and that it is not empty. |
static java.lang.String |
nonEmpty(java.lang.String string,
java.lang.String nameOfObject)
Checks that a
String is not null and that it is not empty. |
static <I,T extends java.util.Collection<I>> |
nonEmpty(T collection)
Checks that a
Collection is not null and that it is not empty. |
static <T extends java.util.Collection<?>> |
nonEmpty(T collection,
java.lang.String nameOfObject)
Checks that a
Collection is not null and that it is not empty. |
static <T> T |
nonNull(T object)
Checks that an Object
object is not null and returns the same object or throws an IllegalArgumentException |
static <T> T |
nonNull(T object,
java.lang.String nameOfObject)
Checks that an
Object is not null and returns the same object or throws an IllegalArgumentException |
static <T> T |
nonNull(T object,
java.util.function.Supplier<java.lang.String> message)
Checks that an
Object is not null and returns the same object or throws an IllegalArgumentException |
static void |
validateArg(boolean condition,
java.lang.String msg) |
static void |
validateArg(boolean condition,
java.util.function.Supplier<java.lang.String> msg) |
public static <T> T nonNull(T object)
object is not null and returns the same object or throws an IllegalArgumentExceptionobject - any Objectjava.lang.IllegalArgumentException - if a o == nullpublic static <T> T nonNull(T object,
java.lang.String nameOfObject)
Object is not null and returns the same object or throws an IllegalArgumentExceptionobject - any ObjectnameOfObject - the name of the object that is being checked for null.
( is used in the exception thrown when o == null.)java.lang.IllegalArgumentException - if a o == nullpublic static <T> T nonNull(T object,
java.util.function.Supplier<java.lang.String> message)
Object is not null and returns the same object or throws an IllegalArgumentExceptionobject - any Objectmessage - the text message that would be passed to the exception thrown when o == null.java.lang.IllegalArgumentException - if a o == nullpublic static <T extends java.util.Collection<?>> T nonEmpty(T collection,
java.lang.String nameOfObject)
Collection is not null and that it is not empty.
If it's non-null and non-empty it returns the input, otherwise it throws an IllegalArgumentExceptioncollection - any CollectionnameOfObject - the name of the object that is being checked for non-emptiness.
( is used in the exception thrown when o.isEmpty().)java.lang.IllegalArgumentException - if collection is null or emptypublic static boolean isNonEmpty(java.util.Collection<?> collection)
Collection is not null and that it is not empty.
If it's non-null and non-empty it returns the truecollection - any Collectionpublic static java.lang.String nonEmpty(java.lang.String string,
java.lang.String nameOfObject)
String is not null and that it is not empty.
If it's non-null and non-empty it returns the input, otherwise it throws an IllegalArgumentExceptionstring - any StringnameOfObject - a message to include in the outputjava.lang.IllegalArgumentException - if string is null or emptypublic static java.lang.String nonEmpty(java.lang.String string)
String is not null and that it is not empty.
If it's non-null and non-empty it returns the input, otherwise it throws an IllegalArgumentExceptionstring - any Stringjava.lang.IllegalArgumentException - if string is null or emptypublic static <I,T extends java.util.Collection<I>> T nonEmpty(T collection)
Collection is not null and that it is not empty.
If it's non-null and non-empty it returns the input, otherwise it throws an IllegalArgumentExceptioncollection - any Collectionjava.lang.IllegalArgumentException - if collection is null or emptypublic static void validateArg(boolean condition,
java.lang.String msg)
public static void validateArg(boolean condition,
java.util.function.Supplier<java.lang.String> msg)