Package com.castlabs.utils

## Class Validate

- java.lang.Object
- - com.castlabs.utils.Validate

-     public class Validate
      extends Object

  Helper class that can be used to validate input.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Validate()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `areEqual​(Bundle b1, Bundle b2)` | Recursively check the bundles for equality
    `static <T> T` | `instanceOf​(Throwable cause, Class<T> cl)` | Search for the specific cause recursively
    `static void` | `isTrue​(boolean expression, String message)` | Validate that the argument condition is `true`; otherwise throwing an exception with the specified message.
    `static void` | `notNull​(Object object)` | Validate that the specified argument is not `null`; otherwise throwing an exception.
    `static void` | `notNull​(Object object, String message)` | Validate that the specified argument is not `null`; otherwise throwing an exception with the specified message.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Validate

          public Validate()

  - ### Method Detail

    - #### notNull

          public static void notNull​(Object object)

      Validate that the specified argument is not `null`; otherwise throwing an exception.

          Validate.notNull(myObject);

      The message of the exception is "The validated object is null".

      Parameters:
        `object` - the object to check
      Throws:
        `IllegalArgumentException` - if the object is `null`

    - #### notNull

          public static void notNull​(Object object,
                                     String message)

      Validate that the specified argument is not `null`; otherwise throwing an exception with the specified message.

          Validate.notNull(myObject, "The object must not be null");

      Parameters:
        `object` - the object to check
        `message` - the exception message if invalid

    - #### isTrue

          public static void isTrue​(boolean expression,
                                    String message)

      Validate that the argument condition is `true`; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

           Validate.isTrue( (i > 0), "The value must be greater than zero");
           Validate.isTrue( myObject.isOk(), "The object is not OK");

      Parameters:
        `expression` - the boolean expression to check
        `message` - the exception message if invalid
      Throws:
        `IllegalArgumentException` - if expression is `false`

    - #### areEqual

          public static boolean areEqual​(@Nullable
                                         Bundle b1,
                                         @Nullable
                                         Bundle b2)

      Recursively check the bundles for equality

      Parameters:
        `b1` - the Bundle to compare
        `b2` - the Bundle to compare
      Returns:
        `true` if the bundles are identical or `false` otherwise

    - #### instanceOf

          @Nullable
          public static <T> T instanceOf​(@Nullable
                                         Throwable cause,
                                         @NonNull
                                         Class<T> cl)

      Search for the specific cause recursively
      Type Parameters:
        `T` - Specific cause type to search for
      Parameters:
        `cause` - Specified container cause
        `cl` - Specific cause class to search for
      Returns:
        Specific cause instance if it was found in the container cause, otherwise `null`