Package com.norconex.commons.lang.function

# Class Predicates<T>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Predicate<T>>
com.norconex.commons.lang.function.Predicates<T>

Type Parameters:
  `T` - type being put to the test

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Iterable<Predicate<T>>`, `Collection<Predicate<T>>`, `Predicate<T>`, `List<Predicate<T>>`, `RandomAccess`

public class Predicates<T> extends ArrayList<Predicate<T>> implements Predicate<T>

A list of `Predicate` instances, matched as a group. This class is an alternative to chaining multiple `Predicate.and(Predicate)` or `Predicate.or(Predicate)`.

By default predicates are tested in order and testing stops after the first one that returned `false`. Only if all predicates return `true` that this predicate list will return `true`.

The behavior is the opposite if the "any" constructor argument is `true`. That is, all predicates are tested in order and stop after the first one returning `true`. Only if all predicates return `false` that this predicate list will return `false`.

Any `null` predicates are simply ignored.

Since:
  2.0.0
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class java.util.AbstractList

  `modCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Predicates()`
  `Predicates(boolean any)`
  `Predicates(int initialCapacity)`
  `Predicates(int initialCapacity, boolean any)`
  `Predicates(Collection<Predicate<T>> predicates)`
  `Predicates(Collection<Predicate<T>> predicates, boolean any)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> Predicates<T>`
  `allOf(@NonNull Predicate<T>... predicates)`
  Group of predicate that returns `true` if all of them returns `true`.
  `static <T> Predicates<T>`
  `anyOf(@NonNull Predicate<T>... predicates)`
  Group of predicate that returns `true` if any of them returns `true`.
  `protected boolean`
  `canEqual(Object other)`
  `boolean`
  `equals(Object o)`
  `int`
  `hashCode()`
  `boolean`
  `isAny()`
  `boolean`
  `test(T t)`
  `String`
  `toString()`

  ### Methods inherited from class java.util.ArrayList

  `add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize`

  ### Methods inherited from class java.util.AbstractCollection

  `containsAll`

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

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, stream, toArray`

  ### Methods inherited from interface java.util.List

  `containsAll`

  ### Methods inherited from interface java.util.function.Predicate

  `and, negate, or`

- ## Constructor Details

  - ### Predicates

    public Predicates()

  - ### Predicates

    public Predicates(boolean any)

  - ### Predicates

    public Predicates(int initialCapacity)

  - ### Predicates

    public Predicates(int initialCapacity, boolean any)

  - ### Predicates

    public Predicates(Collection<Predicate<T>> predicates)

  - ### Predicates

    public Predicates(Collection<Predicate<T>> predicates, boolean any)

- ## Method Details

  - ### isAny

    public boolean isAny()

  - ### test

    public boolean test(T t)
    Specified by:
      `test` in interface `Predicate<T>`

  - ### anyOf

    @SafeVarargs public static <T> Predicates<T> anyOf(@NonNull @NonNull Predicate<T>... predicates)
    Group of predicate that returns `true` if any of them returns `true`.
    Type Parameters:
      `T` - the type of object tested
    Parameters:
      `predicates` - a group of predicates
    Returns:
      a group of predicates
    Since:
      3.0.0

  - ### allOf

    @SafeVarargs public static <T> Predicates<T> allOf(@NonNull @NonNull Predicate<T>... predicates)
    Group of predicate that returns `true` if all of them returns `true`.
    Type Parameters:
      `T` - the type of object tested
    Parameters:
      `predicates` - a group of predicates
    Returns:
      a group of predicates
    Since:
      3.0.0

  - ### equals

    public boolean equals(Object o)
    Specified by:
      `equals` in interface `Collection<T>`
    Specified by:
      `equals` in interface `List<T>`
    Overrides:
      `equals` in class `ArrayList<Predicate<T>>`

  - ### canEqual

    protected boolean canEqual(Object other)

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Collection<T>`
    Specified by:
      `hashCode` in interface `List<T>`
    Overrides:
      `hashCode` in class `ArrayList<Predicate<T>>`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `AbstractCollection<Predicate<T>>`