Package org.opencastproject.util
Class RequireUtil
java.lang.Object
org.opencastproject.util.RequireUtil
Utility functions for handling common requirements.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublebetween(double value, double min, double max) static intmin(int value, int min) static StringThe given value must not be null or empty.static <A> AThe given value must not be null.static StringrequireNotBlank(String value, String valueName) The given string value must not be blank, empty nornull.static voidrequireTrue(boolean expr, String exprName) Require an expression to hold true.
-
Method Details
-
requireTrue
Require an expression to hold true.- Parameters:
expr- the expressionexprName- the name of the expression used to create an error message in caseexprevaluates to false- Throws:
IllegalArgumentException- in caseexprevaluates to false
-
notNull
The given value must not be null.Example:
class A { private String a; A(String a) { this.a = notNull(a, "a"); } }- Parameters:
value- the value to check for nullvalueName- the name of the value; used in error message- Returns:
- the value, if it is not null
- Throws:
IllegalArgumentException- in case ofvaluebeing null
-
notEmpty
The given value must not be null or empty.Example:
class A { private String a; A(String a) { this.a = notEmpty(a, "a"); } }- Parameters:
value- the value to check for emptinessvalueName- the name of the value; used in error message- Returns:
- the value, if it is not empty
- Throws:
IllegalArgumentException- in case ofvaluebeing empty
-
requireNotBlank
The given string value must not be blank, empty nornull. Otherwise, anIllegalArgumentExceptionis thrown.- Parameters:
value- the value to check for not being emptyvalueName- the name of the value- Returns:
- the value, if not blank
-
between
public static double between(double value, double min, double max) -
min
public static int min(int value, int min)
-