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 private
CheckParameterUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
ensureParameterNotNull(java.lang.Object value)
Ensures a parameter is notnull
.static void
ensureParameterNotNull(java.lang.Object value, java.lang.String parameterName)
Ensures a parameter is notnull
static void
ensureThat(boolean condition, java.lang.String message)
Ensures that the conditioncondition
holds.static void
ensureThat(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
Ensures that the conditioncondition
holds.
-
-
-
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 conditioncondition
holds.- 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 conditioncondition
holds. This method can be used when the message is not a plain string literal, but somehow constructed. Using aSupplier
improves 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
-
-