Package org.openstreetmap.josm.tools
Class CheckParameterUtil
- java.lang.Object
-
- org.openstreetmap.josm.tools.CheckParameterUtil
-
public final class CheckParameterUtil extends java.lang.Object
This utility class provides a collection of static helper methods for checking parameters at run-time.- Since:
- 2711
-
-
Constructor Summary
Constructors Modifier Constructor Description privateCheckParameterUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidensureParameterNotNull(java.lang.Object value)Ensures a parameter is notnull.static voidensureParameterNotNull(java.lang.Object value, java.lang.String parameterName)Ensures a parameter is notnullstatic voidensureThat(boolean condition, java.lang.String message)Ensures that the conditionconditionholds.static voidensureThat(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)Ensures that the conditionconditionholds.
-
-
-
Constructor Detail
-
CheckParameterUtil
private CheckParameterUtil()
-
-
Method Detail
-
ensureParameterNotNull
public static void ensureParameterNotNull(java.lang.Object value, java.lang.String parameterName)
Ensures a parameter is notnull- Parameters:
value- The parameter to checkparameterName- The parameter name- Throws:
java.lang.IllegalArgumentException- if the parameter isnull
-
ensureParameterNotNull
public static void ensureParameterNotNull(java.lang.Object value)
Ensures a parameter is notnull. Can find line number in the stack trace, so parameter name is optional- Parameters:
value- The parameter to check- Throws:
java.lang.IllegalArgumentException- if the parameter isnull- Since:
- 3871
-
ensureThat
public static void ensureThat(boolean condition, java.lang.String message)
Ensures that the conditionconditionholds.- Parameters:
condition- The condition to checkmessage- error message- Throws:
java.lang.IllegalArgumentException- if the condition does not hold- See Also:
ensureThat(boolean, Supplier)
-
ensureThat
public static void ensureThat(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Ensures that the conditionconditionholds. This method can be used when the message is not a plain string literal, but somehow constructed. Using aSupplierimproves the performance, as the string construction is skipped when the condition holds.- Parameters:
condition- The condition to checkmessageSupplier- supplier of the error message- Throws:
java.lang.IllegalArgumentException- if the condition does not hold- Since:
- 12822
-
-