almost.functional.utils
public final class Preconditions extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
checkNonEmptyString(java.lang.String reference,
java.lang.String errorMessage)
Check that a String is not empty after removing whitespace.
|
static <T> T |
checkNotNull(T reference,
java.lang.String errorMessage)
Check that a reference is not null, throwing a IllegalArgumentException if it is.
|
static java.lang.Class |
isAssignableTo(java.lang.Class<?> fromValue,
java.lang.Class<?> toValue,
java.lang.String message)
Check that one class is assignable to another.
|
public static <T> T checkNotNull(T reference, java.lang.String errorMessage)
T
- the type of the referencereference
- The reference to checkerrorMessage
- the message for the exception if the reference is nulljava.lang.IllegalArgumentException
- if the reference is nullpublic static java.lang.String checkNonEmptyString(java.lang.String reference, java.lang.String errorMessage)
reference
- the stringerrorMessage
- the message for the exceptionjava.lang.NullPointerException
- if the String is nulljava.lang.IllegalArgumentException
- if the string is non-null but zero lengthpublic static java.lang.Class isAssignableTo(java.lang.Class<?> fromValue, java.lang.Class<?> toValue, java.lang.String message)
fromValue
- the class assigning fromtoValue
- the class assigning tomessage
- the message used in the exception if thrownjava.lang.ClassCastException
- if the assignment can not be made