Package org.apache.commons.collections4.functors

# Class OrPredicate<T>

java.lang.Object
org.apache.commons.collections4.functors.OrPredicate<T>

All Implemented Interfaces:
  `Serializable`, `Predicate<T>`, `PredicateDecorator<T>`, `Predicate<T>`

public final class OrPredicate<T> extends Object implements PredicateDecorator<T>, Serializable
Predicate implementation that returns true if either of the predicates return true.

Since:
  3.0
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OrPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)`
  Constructor that performs no validation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `evaluate(T object)`
  Evaluates the predicate returning true if either predicate returns true.
  `Predicate<? super T>[]`
  `getPredicates()`
  Gets the two predicates being decorated as an array.
  `static <T> Predicate<T>`
  `orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)`
  Factory to create the predicate.

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

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

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

  `and, negate, or`

  ### Methods inherited from interface org.apache.commons.collections4.Predicate

  `test`

- ## Constructor Details

  - ### OrPredicate

    public OrPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
    Constructor that performs no validation. Use `orPredicate` if you want that.
    Parameters:
      `predicate1` - the first predicate to check, not null
      `predicate2` - the second predicate to check, not null

- ## Method Details

  - ### orPredicate

    public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
    Factory to create the predicate.
    Type Parameters:
      `T` - the type that the predicate queries
    Parameters:
      `predicate1` - the first predicate to check, not null
      `predicate2` - the second predicate to check, not null
    Returns:
      the `and` predicate
    Throws:
      `NullPointerException` - if either predicate is null

  - ### evaluate

    public boolean evaluate(T object)
    Evaluates the predicate returning true if either predicate returns true.
    Specified by:
      `evaluate` in interface `Predicate<T>`
    Parameters:
      `object` - the input object
    Returns:
      true if either decorated predicate returns true

  - ### getPredicates

    public Predicate<? super T>[] getPredicates()
    Gets the two predicates being decorated as an array.
    Specified by:
      `getPredicates` in interface `PredicateDecorator<T>`
    Returns:
      the predicates
    Since:
      3.1