com.ibm.openpages.api

## Class Check

- java.lang.Object
- - com.ibm.openpages.api.Check

-     public final class Check
      extends java.lang.Object

  Utility methods for common argument validations

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `checkArgument(boolean expression, java.lang.Object errorMessage)` Ensures the truth of an expression involving one or more parameters to the calling method.
    `static void` | `checkContentsForRange(java.lang.Iterable<java.lang.Integer> iterable, java.lang.Integer min, java.lang.Integer max, java.lang.Object errorMessage)` Ensures that an `Iterable` object passed as a parameter to the calling method is not null and does not contain values that are out of range.
    `static <T extends java.lang.Iterable<?>> T` | `checkContentsNotNull(T iterable, java.lang.Object errorMessage)` Ensures that an `Iterable` object passed as a parameter to the calling method is not null and contains no null elements.
    `static void` | `checkForRange(java.lang.Integer value, java.lang.Integer min, java.lang.Integer max, java.lang.Object errorMessage)` Ensures that a value passed as a parameter to the calling method is in range; otherwise, throws `OpenPagesException`.
    `static java.util.Collection<?>` | `checkNotEmpty(java.util.Collection<?> collection, java.lang.Object errorMessage)` Ensure that an `Collection` object passed as a parameter to the calling method is not empty.
    `static <T> T` | `checkNotNull(T reference)` Ensures that an object reference passed as a parameter to the calling method is not null, throwing a `OpenPagesException` if it is.
    `static <T> T` | `checkNotNull(T reference, java.lang.Object errorMessage)` Ensures that an object reference passed as a parameter to the calling method is not null, throwing a `OpenPagesException` if it is.

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

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

- - ### Method Detail

    - #### checkNotNull

          public static <T> T checkNotNull(T reference,
                                           java.lang.Object errorMessage)

      Ensures that an object reference passed as a parameter to the calling method is not null, throwing a `OpenPagesException` if it is.
      Parameters:
        `reference` - an object reference
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Returns:
        the non-null reference that was validated
      Throws:
        `OpenPagesException` - if `reference` is null

    - #### checkNotNull

          public static <T> T checkNotNull(T reference)

      Ensures that an object reference passed as a parameter to the calling method is not null, throwing a `OpenPagesException` if it is.
      Parameters:
        `reference` - an object reference
      Returns:
        the non-null reference that was validated
      Throws:
        `OpenPagesException` - if `reference` is null

    - #### checkArgument

          public static void checkArgument(boolean expression,
                                           java.lang.Object errorMessage)

      Ensures the truth of an expression involving one or more parameters to the calling method.
      Parameters:
        `expression` - a boolean expression
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Throws:
        `OpenPagesException` - if `expression` is false

    - #### checkContentsNotNull

          public static <T extends java.lang.Iterable<?>> T checkContentsNotNull(T iterable,
                                                                                 java.lang.Object errorMessage)

      Ensures that an `Iterable` object passed as a parameter to the calling method is not null and contains no null elements.
      Parameters:
        `iterable` - any `Iterable` object
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Returns:
        the non-null `iterable` reference just validated
      Throws:
        `OpenPagesException` - if `iterable` is null or contains at least one null element

    - #### checkForRange

          public static void checkForRange(java.lang.Integer value,
                                           java.lang.Integer min,
                                           java.lang.Integer max,
                                           java.lang.Object errorMessage)

      Ensures that a value passed as a parameter to the calling method is in range; otherwise, throws `OpenPagesException`.
      Parameters:
        `value` - the value to test
        `min` - is greater than or equal to
        `max` - is less than or equal to
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Throws:
        `OpenPagesException` - if `value` is out of range.

    - #### checkContentsForRange

          public static void checkContentsForRange(java.lang.Iterable<java.lang.Integer> iterable,
                                                   java.lang.Integer min,
                                                   java.lang.Integer max,
                                                   java.lang.Object errorMessage)

      Ensures that an `Iterable` object passed as a parameter to the calling method is not null and does not contain values that are out of range.
      Parameters:
        `iterable` - any `Iterable` object
        `min` - is greater than or equal to
        `max` - is less than or equal to
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Throws:
        `OpenPagesException` - if `iterable` is null or contains at least one null element

    - #### checkNotEmpty

          public static java.util.Collection<?> checkNotEmpty(java.util.Collection<?> collection,
                                                              java.lang.Object errorMessage)

      Ensure that an `Collection` object passed as a parameter to the calling method is not empty.
      Parameters:
        `collection` - a collection object
        `errorMessage` - the exception message to use if the check fails; will be converted to a string using `String.valueOf(char[])`, if needed
      Returns:
        the non-empty collection that was validated
      Throws:
        `OpenPagesException` - if `collection` is empty

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2021. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.