Class CheckParameterUtil

java.lang.Object
org.openstreetmap.josm.tools.CheckParameterUtil

public final class CheckParameterUtil extends Object
This utility class provides a collection of static helper methods for checking parameters at run-time.
Since:
2711
  • Constructor Details

  • Method Details

    • ensureParameterNotNull

      public static void ensureParameterNotNull(Object value, String parameterName)
      Ensures a parameter is not null
      Parameters:
      value - The parameter to check
      parameterName - The parameter name
      Throws:
      IllegalArgumentException - if the parameter is null
    • ensureParameterNotNull

      public static void ensureParameterNotNull(Object value)
      Ensures a parameter is not null. Can find line number in the stack trace, so parameter name is optional
      Parameters:
      value - The parameter to check
      Throws:
      IllegalArgumentException - if the parameter is null
      Since:
      3871
    • ensureThat

      public static void ensureThat(boolean condition, String message)
      Ensures that the condition condition holds.
      Parameters:
      condition - The condition to check
      message - error message
      Throws:
      IllegalArgumentException - if the condition does not hold
      See Also:
    • ensureThat

      public static void ensureThat(boolean condition, Supplier<String> messageSupplier)
      Ensures that the condition condition holds. This method can be used when the message is not a plain string literal, but somehow constructed. Using a Supplier improves the performance, as the string construction is skipped when the condition holds.
      Parameters:
      condition - The condition to check
      messageSupplier - supplier of the error message
      Throws:
      IllegalArgumentException - if the condition does not hold
      Since:
      12822