Class Preconditions


  • public final class Preconditions
    extends java.lang.Object
    Utility methods for validating objects' status.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T checkArgument​(T object, java.lang.String message)
      Validates if the argument object is null, and throws an IllegalArgumentException if it is.
      static java.lang.String checkArgumentBlank​(java.lang.String object, java.lang.String message)
      Validates if the argument String is blank, and throws an IllegalArgumentException if it is.
      static <T> T checkState​(T object, java.lang.String message)
      Validates if the argument object is null, and throws an IllegalStateException if it is.
      • Methods inherited from class java.lang.Object

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

      • checkArgument

        public static <T> T checkArgument​(T object,
                                          java.lang.String message)
        Validates if the argument object is null, and throws an IllegalArgumentException if it is.
        Type Parameters:
        T - object to check
        Parameters:
        object - the object to validate
        message - the error message to throw the exception with
        Returns:
        the argument object if it is not null
        Throws:
        java.lang.IllegalArgumentException - if the argument object is null
      • checkArgumentBlank

        public static java.lang.String checkArgumentBlank​(java.lang.String object,
                                                          java.lang.String message)
        Validates if the argument String is blank, and throws an IllegalArgumentException if it is.
        Parameters:
        object - the object to validate
        message - the error message to throw the exception with
        Returns:
        the argument String if it is not blank
        Throws:
        java.lang.IllegalArgumentException - if the argument String is blank
      • checkState

        public static <T> T checkState​(T object,
                                       java.lang.String message)
        Validates if the argument object is null, and throws an IllegalStateException if it is.
        Type Parameters:
        T - object to check
        Parameters:
        object - the object to validate
        message - the error message to throw the exception with
        Returns:
        the argument object if it is not null
        Throws:
        java.lang.IllegalStateException - if the argument object is null