Class Args


  • public class Args
    extends java.lang.Object
    A utility class for checking method arguments.
    • Constructor Summary

      Constructors 
      Constructor Description
      Args()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void nullNotPermitted​(java.lang.Object param, java.lang.String name)
      Throws an IllegalArgumentException if the supplied param is null.
      static void requireFinite​(double value, java.lang.String name)
      Checks the supplied value is finite (neither infinite nor NaN) and throws an IllegalArgumentException if the requirement is not met.
      static void requireInRange​(int value, java.lang.String name, int lowerBound, int upperBound)
      Checks that the value falls within the specified range and, if it does not, throws an IllegalArgumentException.
      static void requireNonNegative​(double value, java.lang.String name)
      Throws an IllegalArgumentException if value is negative.
      static void requireNonNegative​(int value, java.lang.String name)
      Throws an IllegalArgumentException if value is negative.
      • Methods inherited from class java.lang.Object

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

      • Args

        public Args()
    • Method Detail

      • nullNotPermitted

        public static void nullNotPermitted​(java.lang.Object param,
                                            java.lang.String name)
        Throws an IllegalArgumentException if the supplied param is null.
        Parameters:
        param - the parameter to check (null permitted).
        name - the name of the parameter (to use in the exception message if param is null).
        Throws:
        java.lang.IllegalArgumentException - if param is null.
      • requireNonNegative

        public static void requireNonNegative​(int value,
                                              java.lang.String name)
        Throws an IllegalArgumentException if value is negative.
        Parameters:
        value - the value.
        name - the parameter name (for use in the exception message).
      • requireNonNegative

        public static void requireNonNegative​(double value,
                                              java.lang.String name)
        Throws an IllegalArgumentException if value is negative.
        Parameters:
        value - the value.
        name - the parameter name (for use in the exception message).
      • requireInRange

        public static void requireInRange​(int value,
                                          java.lang.String name,
                                          int lowerBound,
                                          int upperBound)
        Checks that the value falls within the specified range and, if it does not, throws an IllegalArgumentException.
        Parameters:
        value - the value.
        name - the parameter name.
        lowerBound - the lower bound of the permitted range.
        upperBound - the upper bound fo the permitted range.
      • requireFinite

        public static void requireFinite​(double value,
                                         java.lang.String name)
        Checks the supplied value is finite (neither infinite nor NaN) and throws an IllegalArgumentException if the requirement is not met.
        Parameters:
        value - the value.
        name - the parameter name (for use in the exception message).
        Since:
        1.5.4