Class AndSpec<T>

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

public class AndSpec<T> extends CompositeSpec<T>
A CompositeSpec which requires all its specs to be true in order to evaluate to true.

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

Since:
0.7
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final AndSpec<?>
    The shared AndSpec 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.
    AndSpec(Iterable<? extends Spec<? super T>> specs)
    Creates a spec with the member specs of the given iterable, in iteration order.
    AndSpec(Spec<? super T>... specs)
    Creates a spec with the given member specs, in order.
  • Method Summary

    Modifier and Type
    Method
    Description
    and(Closure spec)
    Returns an AndSpec whose member specs are this spec's, followed by the closure as a spec.
    and(Spec<? super T> spec)
    Returns an AndSpec whose member specs are this spec's, followed by the given one.
    final AndSpec<T>
    and(Spec<? super T>... specs)
    Returns an AndSpec whose member specs are this spec's, followed by the given ones.
    static <T> AndSpec<T>
    Returns the shared AndSpec with no member specs, which is vacuously satisfied by every object.
    @Nullable Spec<? super T>
    Finds the first Spec that is not satisfied by the object.
    boolean
    isSatisfiedBy(T object)
    Returns whether the given element satisfies this spec.

    Methods inherited from class Object

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

    • EMPTY

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

    • AndSpec

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

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

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

    • isSatisfiedBy

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

      public @Nullable Spec<? super T> findUnsatisfiedSpec(T object)
      Finds the first Spec that is not satisfied by the object.
      Parameters:
      object - to check specs against
      Returns:
      the first unsatisfied member spec, or null if all of them are satisfied
      Since:
      7.6
    • and

      @SafeVarargs public final AndSpec<T> and(Spec<? super T>... specs)
      Returns an AndSpec whose member specs are this spec's, followed by the given ones.
      Since:
      0.9
    • and

      public AndSpec<T> and(Spec<? super T> spec)
      Returns an AndSpec whose member specs are this spec's, followed by the given one.
      Since:
      4.3
    • and

      public AndSpec<T> and(Closure spec)
      Returns an AndSpec whose member specs are this spec's, followed by the closure as a spec.
      Since:
      0.9
      See Also:
    • empty

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

      Like every AndSpec, it is immutable, so it is a starting point for building a conjunction. As a member, it does not change which objects satisfy a conjunction.

      Since:
      3.1