Package org.openstreetmap.josm.tools
Class CheckParameterUtil
java.lang.Object
org.openstreetmap.josm.tools.CheckParameterUtil
This utility class provides a collection of static helper methods for checking
parameters at run-time.
- Since:
- 2711
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidensureParameterNotNull(Object value) Ensures a parameter is notnull.static voidensureParameterNotNull(Object value, String parameterName) Ensures a parameter is notnullstatic voidensureThat(boolean condition, String message) Ensures that the conditionconditionholds.static voidensureThat(boolean condition, Supplier<String> messageSupplier) Ensures that the conditionconditionholds.
-
Constructor Details
-
CheckParameterUtil
private CheckParameterUtil()
-
-
Method Details
-
ensureParameterNotNull
Ensures a parameter is notnull- Parameters:
value- The parameter to checkparameterName- The parameter name- Throws:
IllegalArgumentException- if the parameter isnull
-
ensureParameterNotNull
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:
IllegalArgumentException- if the parameter isnull- Since:
- 3871
-
ensureThat
Ensures that the conditionconditionholds.- Parameters:
condition- The condition to checkmessage- error message- Throws:
IllegalArgumentException- if the condition does not hold- See Also:
-
ensureThat
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:
IllegalArgumentException- if the condition does not hold- Since:
- 12822
-