Class OrSpec<T>

java.lang.Object
org.gradle.api.specs.CompositeSpec<T>
org.gradle.api.specs.OrSpec<T>
Type Parameters:
T - The target type for this Spec
All Implemented Interfaces:
Spec<T>

public class OrSpec<T> extends CompositeSpec<T>
A CompositeSpec which requires any one of its specs to be true in order to evaluate to true. As an exception, an OrSpec with no specs is satisfied by every object.

Uses lazy evaluation: member specs are evaluated in order, stopping at the first satisfied one.

Since:
0.7
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final OrSpec<?>
    The shared OrSpec with no member specs, satisfied by every object.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a spec with no member specs, which is satisfied by every object.
    OrSpec(Iterable<? extends Spec<? super T>> specs)
    Creates a spec with the member specs of the given iterable, in iteration order.
    OrSpec(Spec<? super T>... specs)
    Creates a spec with the given member specs, in order.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> OrSpec<T>
    Returns the shared OrSpec with no member specs, which is satisfied by every object.
    boolean
    isSatisfiedBy(T object)
    Returns whether the given element satisfies this spec.
    or(Spec<? super T>... specs)
    Returns an OrSpec whose member specs are this spec's, followed by the given ones.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • EMPTY

      public static final OrSpec<?> EMPTY
      The shared OrSpec with no member specs, satisfied by every object.
      Since:
      3.2
      See Also:
  • Constructor Details

    • OrSpec

      public OrSpec()
      Creates a spec with no member specs, which is satisfied by every object.
      Since:
      3.0
      See Also:
    • OrSpec

      public OrSpec(Spec<? super T>... specs)
      Creates a spec with the given member specs, in order.
      Since:
      0.7
    • OrSpec

      public OrSpec(Iterable<? extends Spec<? super T>> specs)
      Creates a spec with the member specs of the given iterable, in iteration order.
      Since:
      1.3
  • Method Details

    • isSatisfiedBy

      public boolean isSatisfiedBy(T object)
      Description copied from interface: Spec
      Returns whether the given element satisfies this spec.
    • or

      public OrSpec<T> or(Spec<? super T>... specs)
      Returns an OrSpec whose member specs are this spec's, followed by the given ones.
      Since:
      3.2
    • empty

      public static <T> OrSpec<T> empty()
      Returns the shared OrSpec with no member specs, which is satisfied by every object.

      This is an exception to the usual rule that an empty disjunction is false. Like every OrSpec, it is immutable, so it is a starting point for building a disjunction. Its vacuous truth is lost once or(...) is called on it with at least one spec. An OrSpec that has it as a member is satisfied by every object.

      Since:
      3.2