Class 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 not null.
      static void ensureParameterNotNull​(java.lang.Object value, java.lang.String parameterName)
      Ensures a parameter is not null
      static void ensureThat​(boolean condition, java.lang.String message)
      Ensures that the condition condition holds.
      static void ensureThat​(boolean condition, java.util.function.Supplier<java.lang.String> messageSupplier)
      Ensures that the condition condition holds.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • ensureParameterNotNull

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

        public static void ensureParameterNotNull​(java.lang.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:
        java.lang.IllegalArgumentException - if the parameter is null
        Since:
        3871
      • ensureThat

        public static void ensureThat​(boolean condition,
                                      java.lang.String message)
        Ensures that the condition condition holds.
        Parameters:
        condition - The condition to check
        message - 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 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:
        java.lang.IllegalArgumentException - if the condition does not hold
        Since:
        12822