public final class RequireUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static double |
between(double value,
double min,
double max) |
static int |
min(int value,
int min) |
static long |
min(long value,
long min) |
static String |
notEmpty(String value,
String valueName)
The given value must not be null or empty.
|
static <A> A |
notNull(A value,
String valueName)
The given value must not be null.
|
static String |
nullOrNotEmpty(String value,
String valueName)
The value may be null but if it is not null it must not be of size 0.
|
static void |
requireFalse(boolean expr,
String exprName)
Require an expression to be false.
|
static String |
requireNotBlank(String value,
String valueName)
The given string value must not be blank, empty nor
null. |
static void |
requireTrue(boolean expr,
String exprName)
Require an expression to hold true.
|
public static void requireTrue(boolean expr,
String exprName)
expr - the expressionexprName - the name of the expression used to create an error message in case expr evaluates to falseIllegalArgumentException - in case expr evaluates to falsepublic static void requireFalse(boolean expr,
String exprName)
expr - the expressionexprName - the name of the expression used to create an error message in case expr evaluates to falseIllegalArgumentException - in case expr evaluates to truepublic static <A> A notNull(A value,
String valueName)
Example:
class A {
private String a;
A(String a) {
this.a = notNull(a, "a");
}
}
value - the value to check for nullvalueName - the name of the value; used in error messageIllegalArgumentException - in case of value being nullpublic static String notEmpty(String value, String valueName)
Example:
class A {
private String a;
A(String a) {
this.a = notEmpty(a, "a");
}
}
value - the value to check for emptinessvalueName - the name of the value; used in error messageIllegalArgumentException - in case of value being emptypublic static String requireNotBlank(String value, String valueName)
null. Otherwise, an IllegalArgumentException is
thrown.value - the value to check for not being emptyvalueName - the name of the valuepublic static String nullOrNotEmpty(String value, String valueName)
public static double between(double value,
double min,
double max)
public static int min(int value,
int min)
public static long min(long value,
long min)
Copyright © 2009–2020 Opencast Project. All rights reserved.