Class Preconditions


  • public final class Preconditions
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Preconditions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkArgument​(boolean expression)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      static void checkArgument​(boolean expression, java.lang.Object message)
      Ensures the truth of an expression involving one or more parameters to the calling method.
      static void checkNotNull​(java.lang.Object reference)
      Ensures that an object reference passed as a parameter to the calling method is not null.
      static void checkNotNull​(java.lang.Object reference, java.lang.Object message)
      Ensures that an object reference passed as a parameter to the calling method is not null.
      • Methods inherited from class java.lang.Object

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

      • Preconditions

        private Preconditions()
    • Method Detail

      • checkArgument

        public static void checkArgument​(boolean expression,
                                         java.lang.Object message)
        Ensures the truth of an expression involving one or more parameters to the calling method.
        Parameters:
        expression - a boolean expression.
        message - the exception message to use if the check fails; will be converted to a string using String.valueOf(Object)
        Throws:
        java.lang.IllegalArgumentException - if expression is false.
      • checkArgument

        public static void checkArgument​(boolean expression)
        Ensures the truth of an expression involving one or more parameters to the calling method.
        Parameters:
        expression - a boolean expression.
        Throws:
        java.lang.IllegalArgumentException - if expression is false.
      • checkNotNull

        public static void checkNotNull​(java.lang.Object reference,
                                        java.lang.Object message)
        Ensures that an object reference passed as a parameter to the calling method is not null.
        Parameters:
        reference - an object reference.
        message - the exception message to use if the check fails; will be converted to a string using String.valueOf(Object)
        Throws:
        java.lang.IllegalArgumentException - if reference is null.
      • checkNotNull

        public static void checkNotNull​(java.lang.Object reference)
        Ensures that an object reference passed as a parameter to the calling method is not null.
        Parameters:
        reference - an object reference.
        Throws:
        java.lang.IllegalArgumentException - if reference is null.