de.caff.generics.checker

## Class Check

- java.lang.Object
- - de.caff.generics.checker.Check

-     public final class Check
      extends java.lang.Object

  Helper methods for using `Predicate`s as checkers,, useful for combination of checkers.

  The following example only keeps all numbers between 17 and 42 in the outgoing list:

  >        Collection<Integer> foo(Collection<Integer> incoming) {
  >          return Types.filter(incoming,
  >                              Check.and(Check.greaterEquals(17), Check.lessEquals(42)));
  >        }

  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> Predicate1<T>` | `and(java.util.Collection<? extends java.util.function.Predicate<T>> checkers)` Get a value checker which returns the boolean and of some checkers
    `static <T> Predicate1<T>` | `and(java.util.function.Predicate<? super T> checker1, java.util.function.Predicate<? super T> checker2)` Get a value checker which returns the boolean and of two checkers.
    `static <T> Predicate1<T>` | `and(java.util.function.Predicate<? super T> checker1, java.util.function.Predicate<? super T> checker2, java.util.function.Predicate<? super T>... moreCheckers)` Get a value checker which returns the boolean and of some checkers.
    `static <T> Predicate1<T>` | `greaterEquals(java.lang.Comparable<T> element)` Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element, or equal.
    `static <T> Predicate1<T>` | `greaterEquals(T element, java.util.Comparator<T> comparator)` Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element, or equal.
    `static <T> Predicate1<T>` | `greaterThan(java.lang.Comparable<T> element)` Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element.
    `static <T> Predicate1<T>` | `greaterThan(T element, java.util.Comparator<T> comparator)` Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element.
    `static <T> Predicate1<T>` | `isEqual(T value)` Get a value checker with checks for a given value using the equals method.
    `static <T> Predicate1<T>` | `isNotType(java.lang.Class<?> type)` Get a checker which checks whether an object is not an instance of a given class or interface.
    `static <T> Predicate1<T>` | `isType(java.lang.Class<?> type)` Get a checker which checks whether an object is an instance of a given class or interface.
    `static <T> Predicate1<T>` | `lessEquals(java.lang.Comparable<T> element)` Get a checker which compares to a given element, and returns `true` if the checked value is less than the element, or equal.
    `static <T> Predicate1<T>` | `lessEquals(T element, java.util.Comparator<T> comparator)` Get a checker which compares to a given element, and returns `true` if the checked value is less than the element, or equal.
    `static <T> Predicate1<T>` | `lessThan(java.lang.Comparable<T> element)` Get a checker which compares to a given element, and returns `true` if the checked value is less than the element.
    `static <T> Predicate1<T>` | `lessThan(T element, java.util.Comparator<T> comparator)` Get a checker which compares to a given element, and returns `true` if the checked value is less than the element.
    `static <T> Predicate1<T>` | `not(java.util.function.Predicate<T> checker)` Get a value checker which negates the result of a checker.
    `static <T> Predicate1<T>` | `notEquals(T value)` Get a value checker with checks for a given value using the equals method.
    `static <T> Predicate1<T>` | `notRefEquals(T element)` Get a value checker which checks for being not a given value using reference equality.
    `static <T> Predicate1<T>` | `or(java.util.Collection<? extends java.util.function.Predicate<T>> checkers)` Get a value checker which returns the boolean or of some checkers
    `static <T> Predicate1<T>` | `or(java.util.function.Predicate<? super T> checker1, java.util.function.Predicate<? super T> checker2)` Get a value checker which returns the boolean or of two checkers.
    `static <T> Predicate1<T>` | `or(java.util.function.Predicate<? super T> checker1, java.util.function.Predicate<? super T> checker2, java.util.function.Predicate<? super T>... moreCheckers)` Get a value checker which returns the boolean or of some checkers.
    `static <T> Predicate1<T>` | `refEquals(T element)` Get a value checker which checks for a given value using reference equality.
    `static <T> Predicate1<T>` | `xor(java.util.function.Predicate<? super T> checker1, java.util.function.Predicate<? super T> checker2)` Get a value checker which returns the boolean xor of two checkers.

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

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

- - ### Method Detail

    - #### isEqual

          @NotNull
          public static <T> Predicate1<T> isEqual(@NotNull
                                                           T value)

      Get a value checker with checks for a given value using the equals method.
      Type Parameters:
        `T` - value type
      Parameters:
        `value` - value to look for
      Returns:
        equals checker

    - #### notEquals

          @NotNull
          public static <T> Predicate1<T> notEquals(@NotNull
                                                             T value)

      Get a value checker with checks for a given value using the equals method.
      Type Parameters:
        `T` - value type
      Parameters:
        `value` - value to look for
      Returns:
        not equals checker

    - #### refEquals

          @NotNull
          public static <T> Predicate1<T> refEquals(@Nullable
                                                             T element)

      Get a value checker which checks for a given value using reference equality.
      Type Parameters:
        `T` - value type
      Parameters:
        `element` - value to look for
      Returns:
        reference equals checker

    - #### notRefEquals

          @NotNull
          public static <T> Predicate1<T> notRefEquals(@Nullable
                                                                T element)

      Get a value checker which checks for being not a given value using reference equality.
      Type Parameters:
        `T` - value type
      Parameters:
        `element` - value to look for
      Returns:
        reference not equals checker

    - #### and

          @NotNull
          public static <T> Predicate1<T> and(@NotNull
                                                       java.util.function.Predicate<? super T> checker1,
                                                       @NotNull
                                                       java.util.function.Predicate<? super T> checker2)

      Get a value checker which returns the boolean and of two checkers.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker1` - first checker
        `checker2` - second checker
      Returns:
        and checker

    - #### and

          @NotNull
           @SafeVarargs
          public static <T> Predicate1<T> and(@NotNull
                                                                     java.util.function.Predicate<? super T> checker1,
                                                                     @NotNull
                                                                     java.util.function.Predicate<? super T> checker2,
                                                                     @NotNull
                                                                     java.util.function.Predicate<? super T>... moreCheckers)

      Get a value checker which returns the boolean and of some checkers.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker1` - first checker
        `checker2` - second checker
        `moreCheckers` - more checkers
      Returns:
        and checker

    - #### and

          @NotNull
          public static <T> Predicate1<T> and(@NotNull
                                                       java.util.Collection<? extends java.util.function.Predicate<T>> checkers)

      Get a value checker which returns the boolean and of some checkers
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checkers` - checkers collection (must not be empty)
      Returns:
        combined and checker

    - #### or

          @NotNull
          public static <T> Predicate1<T> or(@NotNull
                                                      java.util.function.Predicate<? super T> checker1,
                                                      @NotNull
                                                      java.util.function.Predicate<? super T> checker2)

      Get a value checker which returns the boolean or of two checkers.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker1` - first checker
        `checker2` - second checker
      Returns:
        or checker

    - #### or

          @NotNull
           @SafeVarargs
          public static <T> Predicate1<T> or(@NotNull
                                                                    java.util.function.Predicate<? super T> checker1,
                                                                    @NotNull
                                                                    java.util.function.Predicate<? super T> checker2,
                                                                    @NotNull
                                                                    java.util.function.Predicate<? super T>... moreCheckers)

      Get a value checker which returns the boolean or of some checkers.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker1` - first checker
        `checker2` - second checker
        `moreCheckers` - more checkers
      Returns:
        or checker

    - #### or

          @NotNull
          public static <T> Predicate1<T> or(@NotNull
                                                      java.util.Collection<? extends java.util.function.Predicate<T>> checkers)

      Get a value checker which returns the boolean or of some checkers
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checkers` - checkers collection (must not be empty)
      Returns:
        combined or checker

    - #### xor

          @NotNull
          public static <T> Predicate1<T> xor(@NotNull
                                                       java.util.function.Predicate<? super T> checker1,
                                                       @NotNull
                                                       java.util.function.Predicate<? super T> checker2)

      Get a value checker which returns the boolean xor of two checkers.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker1` - first checker
        `checker2` - second checker
      Returns:
        xor checker

    - #### not

          @NotNull
          public static <T> Predicate1<T> not(@NotNull
                                                       java.util.function.Predicate<T> checker)

      Get a value checker which negates the result of a checker.
      Type Parameters:
        `T` - checked value type
      Parameters:
        `checker` - checker
      Returns:
        negated checker

    - #### lessThan

          @NotNull
          public static <T> Predicate1<T> lessThan(@NotNull
                                                            java.lang.Comparable<T> element)

      Get a checker which compares to a given element, and returns `true` if the checked value is less than the element.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
      Returns:
        less than checker

    - #### lessThan

          @NotNull
          public static <T> Predicate1<T> lessThan(@NotNull
                                                            T element,
                                                            @NotNull
                                                            java.util.Comparator<T> comparator)

      Get a checker which compares to a given element, and returns `true` if the checked value is less than the element.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
        `comparator` - comparator to do the comparison
      Returns:
        less than checker

    - #### lessEquals

          @NotNull
          public static <T> Predicate1<T> lessEquals(@NotNull
                                                              java.lang.Comparable<T> element)

      Get a checker which compares to a given element, and returns `true` if the checked value is less than the element, or equal.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
      Returns:
        less equals checker

    - #### lessEquals

          @NotNull
          public static <T> Predicate1<T> lessEquals(@NotNull
                                                              T element,
                                                              @NotNull
                                                              java.util.Comparator<T> comparator)

      Get a checker which compares to a given element, and returns `true` if the checked value is less than the element, or equal.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
        `comparator` - comparator to do the comparison
      Returns:
        less than checker

    - #### greaterThan

          @NotNull
          public static <T> Predicate1<T> greaterThan(@NotNull
                                                               java.lang.Comparable<T> element)

      Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
      Returns:
        less than checker

    - #### greaterThan

          @NotNull
          public static <T> Predicate1<T> greaterThan(@NotNull
                                                               T element,
                                                               @NotNull
                                                               java.util.Comparator<T> comparator)

      Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
        `comparator` - comparator to do the comparison
      Returns:
        less than checker

    - #### greaterEquals

          @NotNull
          public static <T> Predicate1<T> greaterEquals(@NotNull
                                                                 java.lang.Comparable<T> element)

      Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element, or equal.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
      Returns:
        less equals checker

    - #### greaterEquals

          @NotNull
          public static <T> Predicate1<T> greaterEquals(@NotNull
                                                                 T element,
                                                                 @NotNull
                                                                 java.util.Comparator<T> comparator)

      Get a checker which compares to a given element, and returns `true` if the checked value is greater than the element, or equal.
      Type Parameters:
        `T` - element/value type
      Parameters:
        `element` - element to check against
        `comparator` - comparator to do the comparison
      Returns:
        less than checker

    - #### isType

          @NotNull
          public static <T> Predicate1<T> isType(@NotNull
                                                          java.lang.Class<?> type)

      Get a checker which checks whether an object is an instance of a given class or interface.

      The check is using reflection, namely the `Class.isInstance(Object)` method, which is not considered fast. If you need this check often, rethink your design.

      Type Parameters:
        `T` - checker parameter
      Parameters:
        `type` - class or interface type
      Returns:
        value checker which returns `true` for objects of the given type

    - #### isNotType

          @NotNull
          public static <T> Predicate1<T> isNotType(@NotNull
                                                             java.lang.Class<?> type)

      Get a checker which checks whether an object is not an instance of a given class or interface.

      The check is using reflection, namely the `Class.isInstance(Object)` method, which is not considered fast. If you need this check often, rethink your design.

      Type Parameters:
        `T` - checker parameter
      Parameters:
        `type` - class or interface type
      Returns:
        value checker which returns `true` for objects not of the given type