Class BooleanClosurePredicate<T>

java.lang.Object
org.codehaus.groovy.runtime.BooleanClosurePredicate<T>
All Implemented Interfaces:
Predicate<T>

public class BooleanClosurePredicate<T> extends Object implements Predicate<T>
Adapts a Closure to a Predicate, converting the closure's return value to a boolean using Groovy truth semantics.
Since:
6.0.0
  • Constructor Details

    • BooleanClosurePredicate

      public BooleanClosurePredicate(Closure wrapped)
      Constructs a BooleanClosurePredicate from a Closure.
      Parameters:
      wrapped - the Closure to adapt to a predicate
  • Method Details

    • test

      public boolean test(T arg)
      Tests the given value using the wrapped closure with Groovy truth conversion.
      Specified by:
      test in interface Predicate<T>
      Parameters:
      arg - the value to test
      Returns:
      true if the closure result is truthy by Groovy standards, false otherwise