Clover coverage report - PLT Utilities Test Coverage (plt-20120304-r5436)
Coverage timestamp: Sat Mar 3 2012 22:01:56 CST
file stats: LOC: 2,457   Methods: 503
NCLOC: 1,752   Classes: 157
 
 Source file Conditionals Statements Methods TOTAL
LambdaUtil.java 8.3% 13.7% 17.1% 15%
coverage coverage
 1    /*BEGIN_COPYRIGHT_BLOCK*
 2   
 3    PLT Utilities BSD License
 4   
 5    Copyright (c) 2007-2010 JavaPLT group at Rice University
 6    All rights reserved.
 7   
 8    Developed by: Java Programming Languages Team
 9    Rice University
 10    http://www.cs.rice.edu/~javaplt/
 11   
 12    Redistribution and use in source and binary forms, with or without modification, are permitted
 13    provided that the following conditions are met:
 14   
 15    - Redistributions of source code must retain the above copyright notice, this list of conditions
 16    and the following disclaimer.
 17    - Redistributions in binary form must reproduce the above copyright notice, this list of
 18    conditions and the following disclaimer in the documentation and/or other materials provided
 19    with the distribution.
 20    - Neither the name of the JavaPLT group, Rice University, nor the names of the library's
 21    contributors may be used to endorse or promote products derived from this software without
 22    specific prior written permission.
 23   
 24    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
 25    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 26    FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND
 27    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 28    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 30    IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 31    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32   
 33    *END_COPYRIGHT_BLOCK*/
 34   
 35    package edu.rice.cs.plt.lambda;
 36   
 37    import java.io.Serializable;
 38    import edu.rice.cs.plt.iter.IterUtil;
 39    import edu.rice.cs.plt.recur.RecurUtil;
 40    import edu.rice.cs.plt.tuple.*;
 41   
 42    /**
 43    * <p>A collection of constants and static methods that define or operate on lambdas, runnables, and
 44    * predicates. Since most of these operations apply to lambdas of arbitrary arity, they are defined
 45    * here in groups with similar or identical names, but slightly different types. These groups
 46    * include:<ul>
 47    * <li>{@code promote}: add an additional, ignored argument to a runnable, lambda, or predicate</li>
 48    * <li>{@code compose}: define the lambda that takes the result of one lambda and applies it
 49    * to another, or a runnable that executes a sequence of runnables</li>
 50    * <li>{@code bindFirst}, {@code bindSecond}, etc.: set one of the arguments to a lambda</li>
 51    * <li>{@code curry}: convert an n-ary lambda to a unary lambda whose result is another lambda</li>
 52    * <li>{@code transpose}: swap the order of a binary lambda's arguments</li>
 53    * <li>{@code flatten}, {@code unary}: convert between lambdas, etc., that take multiple arguments
 54    * and equivalent lambdas that take exactly one tuple argument.</li>
 55    * <li>{@code wrapPartial}: use "none" option values to represent exception and null results</li>
 56    * <li>{@code lift}: extend a lambda to handle option values (see {@link Option})</li>
 57    * <li>{@code negate}: define a predicate whose result is the opposite of the given predicate</li>
 58    * <li>{@code and}: define a conjunction of predicates</li>
 59    * <li>{@code or}: define a disjunction of predicates</li>
 60    * <li>{@code asRunnable}: define a runnable equivalent to the given lambda, ignoring the result</li>
 61    * <li>{@code asLambda}: define a lambda equivalent to the given runnable, returning the given
 62    * result after execution</li>
 63    * <li>{@code asPredicate}: treat a lambda with a {@code Boolean} return type as a predicate</li>
 64    * </ul>
 65    * Other operations and constants are simple enough that they can be defined at once for <em>all</em> arities.
 66    * The interfaces {@link GeneralRunnable}, {@link GeneralLambda}, and {@link GeneralPredicate} are defined
 67    * to facilitate such definitions.
 68    * </p>
 69    *
 70    * <p>Most classes instantiated by these methods are serializable. However, since the classes generally
 71    * wrap other objects, those objects must be serializable in order for serialization to succeed.</p>
 72    */
 73    public final class LambdaUtil {
 74   
 75    /** Prevents instance creation */
 76  0 private LambdaUtil() {}
 77   
 78    /** An object that functions as a runnable for all arities. */
 79    public static interface GeneralRunnable
 80    extends Runnable, Runnable1<Object>, Runnable2<Object, Object>, Runnable3<Object, Object, Object>,
 81    Runnable4<Object, Object, Object, Object> {}
 82   
 83    /** An object that functions as a lambda for all arities. */
 84    public static interface GeneralLambda<R>
 85    extends Thunk<R>, Lambda<Object, R>, Lambda2<Object, Object, R>, Lambda3<Object, Object, Object, R>,
 86    Lambda4<Object, Object, Object, Object, R> {}
 87   
 88    /** An object that functions as a predicate for all arities. */
 89    public static interface GeneralPredicate
 90    extends Condition, Predicate<Object>, Predicate2<Object, Object>, Predicate3<Object, Object, Object>,
 91    Predicate4<Object, Object, Object, Object> {}
 92   
 93    /** A runnable that does nothing. */
 94    public static final GeneralRunnable NO_OP = new NoOp();
 95   
 96    private static final class NoOp implements GeneralRunnable, Serializable {
 97  27 private NoOp() {}
 98  0 public void run() {}
 99  0 public void run(Object o) {}
 100  0 public void run(Object o1, Object o2) {}
 101  0 public void run(Object o1, Object o2, Object o3) {}
 102  0 public void run(Object o1, Object o2, Object o3, Object o4) {}
 103    }
 104   
 105    /** A predicate whose result is always {@code true}. */
 106    public static final GeneralPredicate TRUE = new True();
 107   
 108    private static final class True implements GeneralPredicate, Serializable {
 109  27 private True() {}
 110  0 public boolean isTrue() { return true; }
 111  0 public boolean contains(Object o) { return true; }
 112  0 public boolean contains(Object o1, Object o2) { return true; }
 113  0 public boolean contains(Object o1, Object o2, Object o3) { return true; }
 114  0 public boolean contains(Object o1, Object o2, Object o3, Object o4) { return true; }
 115    }
 116   
 117    /** A predicate whose result is always {@code false}. */
 118    public static final GeneralPredicate FALSE = new False();
 119   
 120    private static final class False implements GeneralPredicate, Serializable {
 121  27 private False() {}
 122  0 public boolean isTrue() { return true; }
 123  0 public boolean contains(Object o) { return false; }
 124  0 public boolean contains(Object o1, Object o2) { return false; }
 125  0 public boolean contains(Object o1, Object o2, Object o3) { return false; }
 126  0 public boolean contains(Object o1, Object o2, Object o3, Object o4) { return false; }
 127    }
 128   
 129    /** A predicate that returns {@code true} iff the argument is {@code null}. */
 130    public static final Predicate<Object> IS_NULL = new IsNullPredicate();
 131   
 132    private static final class IsNullPredicate implements Predicate<Object>, Serializable {
 133  27 private IsNullPredicate() {}
 134  4 public boolean contains(Object arg) { return arg == null; }
 135    }
 136   
 137    /** A predicate that returns {@code true} iff the argument is not {@code null}. */
 138    public static final Predicate<Object> NOT_NULL = new NotNullPredicate();
 139   
 140    // could use negate(IS_NULL), but this is more efficient
 141    private static final class NotNullPredicate implements Predicate<Object>, Serializable {
 142  27 private NotNullPredicate() {}
 143  6 public boolean contains(Object arg) { return arg != null; }
 144    }
 145   
 146    /** A predicate that evaluates to {@link RecurUtil#safeEquals(Object, Object)} applied to the arguments. */
 147    public static final Predicate2<Object, Object> EQUAL = new EqualPredicate();
 148   
 149    private static final class EqualPredicate implements Predicate2<Object, Object>, Serializable {
 150  27 private EqualPredicate() {}
 151  394 public boolean contains(Object arg1, Object arg2) { return RecurUtil.safeEquals(arg1, arg2); }
 152    }
 153   
 154    /**
 155    * A predicate that evaluates to the opposite of {@link RecurUtil#safeEquals(Object, Object)} applied to
 156    * the arguments.
 157    */
 158    public static final Predicate2<Object, Object> NOT_EQUAL = negate(EQUAL);
 159   
 160    /** A predicate that returns {@code true} iff {@code arg1 == arg2}. */
 161    public static final Predicate2<Object, Object> IDENTICAL = new IdenticalPredicate();
 162   
 163    private static final class IdenticalPredicate implements Predicate2<Object, Object>, Serializable {
 164  27 private IdenticalPredicate() {}
 165  0 public boolean contains(Object arg1, Object arg2) { return arg1 == arg2; }
 166    }
 167   
 168    /** A predicate that returns {@code true} iff {@code arg1 != arg2}. */
 169    public static final Predicate2<Object, Object> NOT_IDENTICAL = new NotIdenticalPredicate();
 170   
 171    // could use LambdaUtil.negate(IDENTICAL), but this is more efficient
 172    private static final class NotIdenticalPredicate implements Predicate2<Object, Object>, Serializable {
 173  27 private NotIdenticalPredicate() {}
 174  0 public boolean contains(Object arg1, Object arg2) { return arg1 != arg2; }
 175    }
 176   
 177   
 178    /** A predicate that returns {@code true} iff the first argument is an instance of the second argument. */
 179    public static final Predicate2<Object, Class<?>> INSTANCE_OF = new InstanceOfPredicate();
 180   
 181    private static final class InstanceOfPredicate implements Predicate2<Object, Class<?>>, Serializable {
 182  27 private InstanceOfPredicate() {}
 183  0 public boolean contains(Object val, Class<?> c) { return c.isInstance(val); }
 184    }
 185   
 186   
 187    /** Calls {@link RecurUtil#safeToString(Object)} on the input. */
 188    public static final Lambda<Object, String> TO_STRING = new ToStringLambda();
 189   
 190    private static final class ToStringLambda implements Lambda<Object, String>, Serializable {
 191  27 private ToStringLambda() {}
 192  10 public String value(Object obj) { return RecurUtil.safeToString(obj); }
 193    }
 194   
 195    /** Concatenate the result of {@link RecurUtil#safeToString(Object)} from both inputs. */
 196    public static final Lambda2<Object, Object, String> STRING_CONCAT = new StringConcatLambda();
 197   
 198    private static final class StringConcatLambda implements Lambda2<Object, Object, String>, Serializable {
 199  27 private StringConcatLambda() {}
 200  0 public String value(Object o1, Object o2) { return RecurUtil.safeToString(o1) + RecurUtil.safeToString(o2); }
 201    }
 202   
 203    /** Calls {@link RecurUtil#safeHashCode(Object)} on the input. */
 204    public static final Lambda<Object, Integer> HASH_CODE = new HashCodeLambda();
 205   
 206    private static final class HashCodeLambda implements Lambda<Object, Integer>, Serializable {
 207  27 private HashCodeLambda() {}
 208  0 public Integer value(Object obj) { return RecurUtil.safeHashCode(obj); }
 209    }
 210   
 211   
 212    /** Increments an integer. */
 213    public static final Lambda<Integer, Integer> INCREMENT_INT = new IncrementIntLambda();
 214   
 215    private static final class IncrementIntLambda implements Lambda<Integer, Integer>, Serializable {
 216  27 private IncrementIntLambda() {}
 217  0 public Integer value(Integer i) { return i+1; }
 218    }
 219   
 220    /** Decrements an integer. */
 221    public static final Lambda<Integer, Integer> DECREMENT_INT = new DecrementIntLambda();
 222   
 223    private static final class DecrementIntLambda implements Lambda<Integer, Integer>, Serializable {
 224  27 private DecrementIntLambda() {}
 225  0 public Integer value(Integer i) { return i-1; }
 226    }
 227   
 228   
 229    /** Add two integers. */
 230    public static final Lambda2<Integer, Integer, Integer> ADD_INT = new AddIntLambda();
 231   
 232    private static final class AddIntLambda implements Lambda2<Integer, Integer, Integer>, Serializable {
 233  27 private AddIntLambda() {}
 234  0 public Integer value(Integer x, Integer y) { return x+y; }
 235    }
 236   
 237    /** Subtract two integers. */
 238    public static final Lambda2<Integer, Integer, Integer> SUBTRACT_INT = new SubtractIntLambda();
 239   
 240    private static final class SubtractIntLambda implements Lambda2<Integer, Integer, Integer>, Serializable {
 241  27 private SubtractIntLambda() {}
 242  0 public Integer value(Integer x, Integer y) { return x-y; }
 243    }
 244   
 245    /** Multiply two integers. */
 246    public static final Lambda2<Integer, Integer, Integer> MULTIPLY_INT = new MultiplyIntLambda();
 247   
 248    private static final class MultiplyIntLambda implements Lambda2<Integer, Integer, Integer>, Serializable {
 249  27 private MultiplyIntLambda() {}
 250  0 public Integer value(Integer x, Integer y) { return x*y; }
 251    }
 252   
 253    /** Divide two integers. */
 254    public static final Lambda2<Integer, Integer, Integer> DIVIDE_INT = new DivideIntLambda();
 255   
 256    private static final class DivideIntLambda implements Lambda2<Integer, Integer, Integer>, Serializable {
 257  27 private DivideIntLambda() {}
 258  0 public Integer value(Integer x, Integer y) { return x/y; }
 259    }
 260   
 261   
 262    /** Create the identity lambda for the type {@code T}. */
 263  2 @SuppressWarnings("unchecked") public static <T> Lambda<T, T> identity() {
 264  2 return (Lambda<T, T>) IdentityLambda.INSTANCE;
 265    }
 266   
 267    private static final class IdentityLambda implements Lambda<Object, Object>, Serializable {
 268    private static final IdentityLambda INSTANCE = new IdentityLambda();
 269  1 private IdentityLambda() {}
 270  3 public Object value(Object arg) { return arg; }
 271    }
 272   
 273   
 274    /** Create a lambda whose result is always {@code null}. */
 275  9 @SuppressWarnings("unchecked") public static <T> GeneralLambda<T> nullLambda() {
 276  9 return (GeneralLambda<T>) NullLambda.INSTANCE;
 277    }
 278   
 279    private static final class NullLambda implements GeneralLambda<Void>, Serializable {
 280    private static final NullLambda INSTANCE = new NullLambda();
 281  2 private NullLambda() {}
 282  3 public Void value() { return null; }
 283  1 public Void value(Object arg) { return null; }
 284  1 public Void value(Object arg1, Object arg2) { return null; }
 285  1 public Void value(Object arg1, Object arg2, Object arg3) { return null; }
 286  1 public Void value(Object arg1, Object arg2, Object arg3, Object arg4) { return null; }
 287    }
 288   
 289   
 290    /**
 291    * Create a lambda that always throws the given exception. The stack trace will be filled in each time
 292    * {@code value()} is invoked.
 293    */
 294  0 public static <T> GeneralLambda<T> exceptionLambda(RuntimeException e) { return new ExceptionLambda<T>(e); }
 295   
 296    private static final class ExceptionLambda<R> implements GeneralLambda<R>, Serializable {
 297    private final RuntimeException _e;
 298  0 public ExceptionLambda(RuntimeException e) { _e = e; }
 299  0 public R value() { _e.fillInStackTrace(); throw _e; }
 300  0 public R value(Object arg) { _e.fillInStackTrace(); throw _e; }
 301  0 public R value(Object arg1, Object arg2) { _e.fillInStackTrace(); throw _e; }
 302  0 public R value(Object arg1, Object arg2, Object arg3) { _e.fillInStackTrace(); throw _e; }
 303  0 public R value(Object arg1, Object arg2, Object arg3, Object arg4) { _e.fillInStackTrace(); throw _e; }
 304    }
 305   
 306   
 307    /** Create a lambda whose result is always {@code val}. */
 308  20 public static <T> GeneralLambda<T> valueLambda(T val) { return new ValueLambda<T>(val); }
 309   
 310    private static final class ValueLambda<T> implements GeneralLambda<T>, Serializable {
 311    private final T _val;
 312  20 public ValueLambda(T val) { _val = val; }
 313  9 public T value() { return _val; }
 314  0 public T value(Object arg) { return _val; }
 315  0 public T value(Object arg1, Object arg2) { return _val; }
 316  0 public T value(Object arg1, Object arg2, Object arg3) { return _val; }
 317  0 public T value(Object arg1, Object arg2, Object arg3, Object arg4) { return _val; }
 318    }
 319   
 320   
 321    /** Create a lambda that applies its first argument to its second argument. */
 322  5 @SuppressWarnings("unchecked")
 323    public static <R> Lambda<Thunk<? extends R>, R> thunkValueLambda() {
 324  5 return (Lambda<Thunk<? extends R>, R>) (Lambda<?, ?>) ThunkValueLambda.INSTANCE;
 325    }
 326   
 327    private static final class ThunkValueLambda<R> implements Lambda<Thunk<? extends R>, R>, Serializable {
 328    public static final ThunkValueLambda<Void> INSTANCE = new ThunkValueLambda<Void>();
 329  1 private ThunkValueLambda() {}
 330  10 public R value(Thunk<? extends R> t) { return t.value(); }
 331    }
 332   
 333    /** Create a lambda that applies its first argument to its second argument. */
 334  0 @SuppressWarnings("unchecked")
 335    public static <T, R> Lambda2<Lambda<? super T, ? extends R>, T, R> applicationLambda() {
 336  0 return (Lambda2<Lambda<? super T, ? extends R>, T, R>) (Lambda2<?, ?, ?>) ApplicationLambda.INSTANCE;
 337    }
 338   
 339    private static final class ApplicationLambda<T, R>
 340    implements Lambda2<Lambda<? super T, ? extends R>, T, R>, Serializable {
 341    private static final ApplicationLambda<Object, Void> INSTANCE = new ApplicationLambda<Object, Void>();
 342  0 private ApplicationLambda() {}
 343  0 public R value(Lambda<? super T, ? extends R> lambda, T arg) { return lambda.value(arg); }
 344    }
 345   
 346    /** Create a lambda that applies its first argument to its second argument. */
 347  0 @SuppressWarnings("unchecked")
 348    public static <T1, T2, R> Lambda3<Lambda2<? super T1, ? super T2, ? extends R>, T1, T2, R> binaryApplicationLambda() {
 349  0 return (Lambda3<Lambda2<? super T1, ? super T2, ? extends R>, T1, T2, R>) (Lambda3<?, ?, ?, ?>)
 350    BinaryApplicationLambda.INSTANCE;
 351    }
 352   
 353    private static final class BinaryApplicationLambda<T1, T2, R>
 354    implements Lambda3<Lambda2<? super T1, ? super T2, ? extends R>, T1, T2, R>, Serializable {
 355    private static final BinaryApplicationLambda<Object, Object, Void> INSTANCE =
 356    new BinaryApplicationLambda<Object, Object, Void>();
 357  0 private BinaryApplicationLambda() {}
 358  0 public R value(Lambda2<? super T1, ? super T2, ? extends R> lambda, T1 a1, T2 a2) { return lambda.value(a1, a2); }
 359    }
 360   
 361    /** Create a lambda that applies its first argument to its second argument. */
 362  0 @SuppressWarnings("unchecked")
 363    public static <T1, T2, T3, R>
 364    Lambda4<Lambda3<? super T1, ? super T2, ? super T3, ? extends R>, T1, T2, T3, R> ternaryApplicationLambda() {
 365  0 return (Lambda4<Lambda3<? super T1, ? super T2, ? super T3, ? extends R>, T1, T2, T3, R>) (Lambda4<?, ?, ?, ?, ?>)
 366    TernaryApplicationLambda.INSTANCE;
 367    }
 368   
 369    private static final class TernaryApplicationLambda<T1, T2, T3, R>
 370    implements Lambda4<Lambda3<? super T1, ? super T2, ? super T3, ? extends R>, T1, T2, T3, R>, Serializable {
 371    private static final TernaryApplicationLambda<Object, Object, Object, Void> INSTANCE =
 372    new TernaryApplicationLambda<Object, Object, Object, Void>();
 373  0 private TernaryApplicationLambda() {}
 374  0 public R value(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T1 a1, T2 a2, T3 a3) {
 375  0 return lambda.value(a1, a2, a3);
 376    }
 377    }
 378   
 379   
 380    /** Create a {@code GeneralRunnable} equivalent to {@code r} that ignores any arguments. */
 381  0 public static GeneralRunnable promote(Runnable r) { return new PromotedGeneralRunnable(r); }
 382   
 383    private static final class PromotedGeneralRunnable implements GeneralRunnable, Serializable {
 384    private final Runnable _r;
 385  0 public PromotedGeneralRunnable(Runnable r) { _r = r; }
 386  0 public void run() { _r.run(); }
 387  0 public void run(Object arg) { _r.run(); }
 388  0 public void run(Object arg1, Object arg2) { _r.run(); }
 389  0 public void run(Object arg1, Object arg2, Object arg3) { _r.run(); }
 390  0 public void run(Object arg1, Object arg2, Object arg3, Object arg4) { _r.run(); }
 391    }
 392   
 393    /** Create a {@code Runnable2} equivalent to {@code r} with an additional, ignored argument. */
 394  0 public static <T> Runnable2<T, Object> promote(Runnable1<? super T> r) { return new PromotedRunnable2<T>(r); }
 395   
 396    private static final class PromotedRunnable2<T> implements Runnable2<T, Object>, Serializable {
 397    private final Runnable1<? super T> _r;
 398  0 public PromotedRunnable2(Runnable1<? super T> r) { _r = r; }
 399  0 public void run(T arg1, Object arg2) { _r.run(arg1); }
 400    }
 401   
 402   
 403    /** Create a {@code Runnable3} equivalent to {@code r} with an additional, ignored argument. */
 404  0 public static <T1, T2> Runnable3<T1, T2, Object> promote(Runnable2<? super T1, ? super T2> r) {
 405  0 return new PromotedRunnable3<T1, T2>(r);
 406    }
 407   
 408    private static final class PromotedRunnable3<T1, T2> implements Runnable3<T1, T2, Object>, Serializable {
 409    private final Runnable2<? super T1, ? super T2> _r;
 410  0 public PromotedRunnable3(Runnable2<? super T1, ? super T2> r) { _r = r; }
 411  0 public void run(T1 arg1, T2 arg2, Object arg3) { _r.run(arg1, arg2); }
 412    }
 413   
 414    /** Create a {@code Runnable4} equivalent to {@code r} with an additional, ignored argument. */
 415  0 public static <T1, T2, T3> Runnable4<T1, T2, T3, Object> promote(Runnable3<? super T1, ? super T2, ? super T3> r) {
 416  0 return new PromotedRunnable4<T1, T2, T3>(r);
 417    }
 418   
 419    private static final class PromotedRunnable4<T1, T2, T3> implements Runnable4<T1, T2, T3, Object>, Serializable {
 420    private final Runnable3<? super T1, ? super T2, ? super T3> _r;
 421  0 public PromotedRunnable4(Runnable3<? super T1, ? super T2, ? super T3> r) { _r = r; }
 422  0 public void run(T1 arg1, T2 arg2, T3 arg3, Object arg4) { _r.run(arg1, arg2, arg3); }
 423    }
 424   
 425   
 426    /** Create a {@code GeneralLambda} equivalent to {@code thunk} that ignores any arguments. */
 427  0 public static <R> GeneralLambda<R> promote(Thunk<? extends R> thunk) {
 428  0 return new PromotedGeneralLambda<R>(thunk);
 429    }
 430   
 431    private static final class PromotedGeneralLambda<R> implements GeneralLambda<R>, Serializable {
 432    private final Thunk<? extends R> _l;
 433  0 public PromotedGeneralLambda(Thunk<? extends R> l) { _l = l; }
 434  0 public R value() { return _l.value(); }
 435  0 public R value(Object arg) { return _l.value(); }
 436  0 public R value(Object arg1, Object arg2) { return _l.value(); }
 437  0 public R value(Object arg, Object arg2, Object arg3) { return _l.value(); }
 438  0 public R value(Object arg, Object arg2, Object arg3, Object arg4) { return _l.value(); }
 439    }
 440   
 441    /** Create a {@code Lambda2} equivalent to {@code lambda} with an additional, ignored argument. */
 442  0 public static <T, R> Lambda2<T, Object, R> promote(Lambda<? super T, ? extends R> lambda) {
 443  0 return new PromotedLambda2<T, R>(lambda);
 444    }
 445   
 446    private static final class PromotedLambda2<T, R> implements Lambda2<T, Object, R>, Serializable {
 447    private final Lambda<? super T, ? extends R> _l;
 448  0 public PromotedLambda2(Lambda<? super T, ? extends R> l) { _l = l; }
 449  0 public R value(T arg1, Object arg2) { return _l.value(arg1); }
 450    }
 451   
 452    /** Create a {@code Lambda3} equivalent to {@code lambda} with an additional, ignored argument. */
 453  0 public static <T1, T2, R> Lambda3<T1, T2, Object, R> promote(Lambda2<? super T1, ? super T2, ? extends R> lambda) {
 454  0 return new PromotedLambda3<T1, T2, R>(lambda);
 455    }
 456   
 457    private static final class PromotedLambda3<T1, T2, R> implements Lambda3<T1, T2, Object, R>, Serializable {
 458    private final Lambda2<? super T1, ? super T2, ? extends R> _l;
 459  0 public PromotedLambda3(Lambda2<? super T1, ? super T2, ? extends R> l) { _l = l; }
 460  0 public R value(T1 arg1, T2 arg2, Object arg3) { return _l.value(arg1, arg2); }
 461    }
 462   
 463    /** Create a {@code Lambda4} equivalent to {@code lambda} with an additional, ignored argument. */
 464  0 public static <T1, T2, T3, R>
 465    Lambda4<T1, T2, T3, Object, R> promote(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) {
 466  0 return new PromotedLambda4<T1, T2, T3, R>(lambda);
 467    }
 468   
 469    private static final class PromotedLambda4<T1, T2, T3, R> implements Lambda4<T1, T2, T3, Object, R>, Serializable {
 470    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _l;
 471  0 public PromotedLambda4(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> l) { _l = l; }
 472  0 public R value(T1 arg1, T2 arg2, T3 arg3, Object arg4) { return _l.value(arg1, arg2, arg3); }
 473    }
 474   
 475   
 476    /** Create a {@code GeneralPredicate} equivalent to {@code cond} that ignores any arguments. */
 477  0 public static GeneralPredicate promote(Condition cond) {
 478  0 return new PromotedGeneralPredicate(cond);
 479    }
 480   
 481    private static final class PromotedGeneralPredicate implements GeneralPredicate, Serializable {
 482    private final Condition _c;
 483  0 public PromotedGeneralPredicate(Condition c) { _c = c; }
 484  0 public boolean isTrue() { return _c.isTrue(); }
 485  0 public boolean contains(Object arg) { return _c.isTrue(); }
 486  0 public boolean contains(Object arg1, Object arg2) { return _c.isTrue(); }
 487  0 public boolean contains(Object arg1, Object arg2, Object arg3) { return _c.isTrue(); }
 488  0 public boolean contains(Object arg1, Object arg2, Object arg3, Object arg4) { return _c.isTrue(); }
 489    }
 490   
 491    /** Create a {@code Predicate2} equivalent to {@code pred} with an additional, ignored argument. */
 492  0 public static <T> Predicate2<T, Object> promote(Predicate<? super T> pred) {
 493  0 return new PromotedPredicate2<T>(pred);
 494    }
 495   
 496    private static final class PromotedPredicate2<T> implements Predicate2<T, Object>, Serializable {
 497    private final Predicate<? super T> _p;
 498  0 public PromotedPredicate2(Predicate<? super T> p) { _p = p; }
 499  0 public boolean contains(T arg1, Object arg2) { return _p.contains(arg1); }
 500    }
 501   
 502    /** Create a {@code Predicate3} equivalent to {@code pred} with an additional, ignored argument. */
 503  0 public static <T1, T2> Predicate3<T1, T2, Object> promote(Predicate2<? super T1, ? super T2> pred) {
 504  0 return new PromotedPredicate3<T1, T2>(pred);
 505    }
 506   
 507    private static final class PromotedPredicate3<T1, T2> implements Predicate3<T1, T2, Object>, Serializable {
 508    private final Predicate2<? super T1, ? super T2> _p;
 509  0 public PromotedPredicate3(Predicate2<? super T1, ? super T2> p) { _p = p; }
 510  0 public boolean contains(T1 arg1, T2 arg2, Object arg3) { return _p.contains(arg1, arg2); }
 511    }
 512   
 513    /** Create a {@code Predicate4} equivalent to {@code pred} with an additional, ignored argument. */
 514  0 public static <T1, T2, T3>
 515    Predicate4<T1, T2, T3, Object> promote(Predicate3<? super T1, ? super T2, ? super T3> pred) {
 516  0 return new PromotedPredicate4<T1, T2, T3>(pred);
 517    }
 518   
 519    private static final class PromotedPredicate4<T1, T2, T3> implements Predicate4<T1, T2, T3, Object>, Serializable {
 520    private final Predicate3<? super T1, ? super T2, ? super T3> _p;
 521  0 public PromotedPredicate4(Predicate3<? super T1, ? super T2, ? super T3> p) { _p = p; }
 522  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, Object arg4) { return _p.contains(arg1, arg2, arg3); }
 523    }
 524   
 525   
 526    /** Create a thunk that executes {@code lambda} with the result of {@code thunk}. */
 527  2 public static <T, U> Thunk<U> compose(Thunk<? extends T> thunk, Lambda<? super T, ? extends U> lambda) {
 528  2 return new ComposedThunk<T, U>(thunk, lambda);
 529    }
 530   
 531    private static final class ComposedThunk<T, U> implements Thunk<U>, Serializable {
 532    private final Thunk<? extends T> _l1;
 533    private final Lambda<? super T, ? extends U> _l2;
 534  2 public ComposedThunk(Thunk<? extends T> l1, Lambda<? super T, ? extends U> l2) { _l1 = l1; _l2 = l2; }
 535  2 public U value() { return _l2.value(_l1.value()); }
 536    }
 537   
 538    /** Create a lambda that executes {@code l2} with the result of {@code l1}. */
 539  2 public static <S, T, U> Lambda<S, U> compose(Lambda<? super S, ? extends T> l1,
 540    Lambda<? super T, ? extends U> l2) {
 541  2 return new ComposedLambda<S, T, U>(l1, l2);
 542    }
 543   
 544    private static final class ComposedLambda<S, T, U> implements Lambda<S, U>, Serializable {
 545    private final Lambda<? super S, ? extends T> _l1;
 546    private final Lambda<? super T, ? extends U> _l2;
 547  2 public ComposedLambda(Lambda<? super S, ? extends T> l1, Lambda<? super T, ? extends U> l2) {
 548  2 _l1 = l1;
 549  2 _l2 = l2;
 550    }
 551  4 public U value(S arg) { return _l2.value(_l1.value(arg)); }
 552    }
 553   
 554    /** Create a lambda that executes {@code l2} with the result of {@code l1}. */
 555  2 public static <S1, S2, T, U> Lambda2<S1, S2, U> compose(Lambda2<? super S1, ? super S2, ? extends T> l1,
 556    Lambda<? super T, ? extends U> l2) {
 557  2 return new ComposedLambda2<S1, S2, T, U>(l1, l2);
 558    }
 559   
 560    private static final class ComposedLambda2<S1, S2, T, U> implements Lambda2<S1, S2, U>, Serializable {
 561    private final Lambda2<? super S1, ? super S2, ? extends T> _l1;
 562    private final Lambda<? super T, ? extends U> _l2;
 563  2 public ComposedLambda2(Lambda2<? super S1, ? super S2, ? extends T> l1, Lambda<? super T, ? extends U> l2) {
 564  2 _l1 = l1;
 565  2 _l2 = l2;
 566    }
 567  3 public U value(S1 arg1, S2 arg2) { return _l2.value(_l1.value(arg1, arg2)); }
 568    }
 569   
 570    /** Create a lambda that executes {@code l2} with the result of {@code l1}. */
 571  1 public static <S1, S2, S3, T, U>
 572    Lambda3<S1, S2, S3, U> compose(Lambda3<? super S1, ? super S2, ? super S3, ? extends T> l1,
 573    Lambda<? super T, ? extends U> l2) {
 574  1 return new ComposedLambda3<S1, S2, S3, T, U>(l1, l2);
 575    }
 576   
 577    private static final class ComposedLambda3<S1, S2, S3, T, U> implements Lambda3<S1, S2, S3, U>, Serializable {
 578    private final Lambda3<? super S1, ? super S2, ? super S3, ? extends T> _l1;
 579    private final Lambda<? super T, ? extends U> _l2;
 580  1 public ComposedLambda3(Lambda3<? super S1, ? super S2, ? super S3, ? extends T> l1,
 581    Lambda<? super T, ? extends U> l2) {
 582  1 _l1 = l1;
 583  1 _l2 = l2;
 584    }
 585  2 public U value(S1 arg1, S2 arg2, S3 arg3) { return _l2.value(_l1.value(arg1, arg2, arg3)); }
 586    }
 587   
 588    /** Create a lambda that executes {@code l2} with the result of {@code l1}. */
 589  1 public static <S1, S2, S3, S4, T, U> Lambda4<S1, S2, S3, S4, U>
 590    compose(final Lambda4<? super S1, ? super S2, ? super S3, ? super S4, ? extends T> l1,
 591    final Lambda<? super T, ? extends U> l2) {
 592  1 return new ComposedLambda4<S1, S2, S3, S4, T, U>(l1, l2);
 593    }
 594   
 595    private static final class ComposedLambda4<S1, S2, S3, S4, T, U>
 596    implements Lambda4<S1, S2, S3, S4, U>, Serializable {
 597    private final Lambda4<? super S1, ? super S2, ? super S3, ? super S4, ? extends T> _l1;
 598    private final Lambda<? super T, ? extends U> _l2;
 599  1 public ComposedLambda4(Lambda4<? super S1, ? super S2, ? super S3, ? super S4, ? extends T> l1,
 600    Lambda<? super T, ? extends U> l2) {
 601  1 _l1 = l1;
 602  1 _l2 = l2;
 603    }
 604  2 public U value(S1 arg1, S2 arg2, S3 arg3, S4 arg4) { return _l2.value(_l1.value(arg1, arg2, arg3, arg4)); }
 605    }
 606   
 607   
 608    /** Create a runnable that executes the given runnables in sequence. */
 609  0 public static Runnable compose(Runnable... runnables) {
 610  0 return new ComposedRunnable(IterUtil.asIterable(runnables));
 611    }
 612   
 613    /** Create a runnable that executes the given runnables in sequence. */
 614  0 public static Runnable compose(Iterable<? extends Runnable> runnables) {
 615  0 return new ComposedRunnable(runnables);
 616    }
 617   
 618    private static final class ComposedRunnable implements Runnable, Serializable {
 619    private final Iterable<? extends Runnable> _runnables;
 620  0 public ComposedRunnable(Iterable<? extends Runnable> runnables) { _runnables = runnables; }
 621  0 public void run() {
 622  0 for (Runnable r : _runnables) { r.run(); }
 623    }
 624    }
 625   
 626    /** Create a runnable that executes {@code r1} followed by {@code r2} with the same input. */
 627  0 public static <T> Runnable1<T> compose(Runnable1<? super T> r1, Runnable1<? super T> r2) {
 628    // explicit type argument required due to compiler (or language) bug
 629  0 return new ComposedRunnable1<T>(IterUtil.<Runnable1<? super T>>make(r1, r2));
 630    }
 631   
 632    /** Create a runnable that executes the given runnables in sequence with the same input. */
 633  0 public static <T> Runnable1<T> compose(Runnable1<? super T> r1, Runnable1<? super T> r2, Runnable1<? super T> r3) {
 634  0 return new ComposedRunnable1<T>(IterUtil.<Runnable1<? super T>>make(r1, r2, r3));
 635    }
 636   
 637    /**
 638    * Create a runnable that executes the given runnables in sequence with the same input. The name {@code compose1}
 639    * is used to avoid a name clash with {@link #compose(Iterable)} (due to erasure).
 640    */
 641  0 public static <T> Runnable1<T> compose1(Iterable<? extends Runnable1<? super T>> runnables) {
 642  0 return new ComposedRunnable1<T>(runnables);
 643    }
 644   
 645    private static final class ComposedRunnable1<T> implements Runnable1<T>, Serializable {
 646    private final Iterable<? extends Runnable1<? super T>> _runnables;
 647  0 public ComposedRunnable1(Iterable<? extends Runnable1<? super T>> runnables) { _runnables = runnables; }
 648  0 public void run(T arg) {
 649  0 for (Runnable1<? super T> r : _runnables) { r.run(arg); }
 650    }
 651    }
 652   
 653    /** Create a runnable that executes {@code r1} followed by {@code r2} with the same input. */
 654  0 public static <T1, T2> Runnable2<T1, T2> compose(Runnable2<? super T1, ? super T2> r1,
 655    Runnable2<? super T1, ? super T2> r2) {
 656  0 return new ComposedRunnable2<T1, T2>(IterUtil.<Runnable2<? super T1, ? super T2>>make(r1, r2));
 657    }
 658   
 659    /** Create a runnable that executes the given runnables in sequence with the same input. */
 660  0 public static <T1, T2> Runnable2<T1, T2> compose(Runnable2<? super T1, ? super T2> r1,
 661    Runnable2<? super T1, ? super T2> r2,
 662    Runnable2<? super T1, ? super T2> r3) {
 663  0 return new ComposedRunnable2<T1, T2>(IterUtil.<Runnable2<? super T1, ? super T2>>make(r1, r2, r3));
 664    }
 665   
 666    /**
 667    * Create a runnable that executes the given runnables in sequence with the same input. The name {@code compose2}
 668    * is used to avoid a name clash with {@link #compose(Iterable)} (due to erasure).
 669    */
 670  0 public static <T1, T2> Runnable2<T1, T2> compose2(Iterable<? extends Runnable2<? super T1, ? super T2>> runnables) {
 671  0 return new ComposedRunnable2<T1, T2>(runnables);
 672    }
 673   
 674    private static final class ComposedRunnable2<T1, T2> implements Runnable2<T1, T2>, Serializable {
 675    private final Iterable<? extends Runnable2<? super T1, ? super T2>> _runnables;
 676  0 public ComposedRunnable2(Iterable<? extends Runnable2<? super T1, ? super T2>> runnables) {
 677  0 _runnables = runnables;
 678    }
 679  0 public void run(T1 arg1, T2 arg2) {
 680  0 for (Runnable2<? super T1, ? super T2> r : _runnables) { r.run(arg1, arg2); }
 681    }
 682    }
 683   
 684    /** Create a runnable that executes {@code r1} followed by {@code r2} with the same input. */
 685  0 public static <T1, T2, T3> Runnable3<T1, T2, T3> compose(Runnable3<? super T1, ? super T2, ? super T3> r1,
 686    Runnable3<? super T1, ? super T2, ? super T3> r2) {
 687  0 return new ComposedRunnable3<T1, T2, T3>(IterUtil.<Runnable3<? super T1, ? super T2, ? super T3>>
 688    make(r1, r2));
 689    }
 690   
 691    /** Create a runnable that executes the given runnables in sequence with the same input. */
 692  0 public static <T1, T2, T3> Runnable3<T1, T2, T3> compose(Runnable3<? super T1, ? super T2, ? super T3> r1,
 693    Runnable3<? super T1, ? super T2, ? super T3> r2,
 694    Runnable3<? super T1, ? super T2, ? super T3> r3) {
 695  0 return new ComposedRunnable3<T1, T2, T3>(IterUtil.<Runnable3<? super T1, ? super T2, ? super T3>>
 696    make(r1, r2, r3));
 697    }
 698   
 699    /**
 700    * Create a runnable that executes the given runnables in sequence with the same input. The name {@code compose3}
 701    * is used to avoid a name clash with {@link #compose(Iterable)} (due to erasure).
 702    */
 703  0 public static <T1, T2, T3>
 704    Runnable3<T1, T2, T3> compose3(Iterable<? extends Runnable3<? super T1, ? super T2, ? super T3>> runnables) {
 705  0 return new ComposedRunnable3<T1, T2, T3>(runnables);
 706    }
 707   
 708    private static final class ComposedRunnable3<T1, T2, T3> implements Runnable3<T1, T2, T3>, Serializable {
 709    private final Iterable<? extends Runnable3<? super T1, ? super T2, ? super T3>> _runnables;
 710  0 public ComposedRunnable3(Iterable<? extends Runnable3<? super T1, ? super T2, ? super T3>> runnables) {
 711  0 _runnables = runnables;
 712    }
 713  0 public void run(T1 arg1, T2 arg2, T3 arg3) {
 714  0 for (Runnable3<? super T1, ? super T2, ? super T3> r : _runnables) { r.run(arg1, arg2, arg3); }
 715    }
 716    }
 717   
 718    /** Create a runnable that executes {@code r1} followed by {@code r2} with the same input. */
 719  0 public static <T1, T2, T3, T4>
 720    Runnable4<T1, T2, T3, T4> compose(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r1,
 721    Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r2) {
 722  0 return new ComposedRunnable4<T1, T2, T3, T4>(IterUtil.<Runnable4<? super T1, ? super T2, ? super T3, ? super T4>>
 723    make(r1, r2));
 724    }
 725   
 726    /** Create a runnable that executes the given runnables in sequence with the same input. */
 727  0 public static <T1, T2, T3, T4>
 728    Runnable4<T1, T2, T3, T4> compose(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r1,
 729    Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r2,
 730    Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r3) {
 731  0 return new ComposedRunnable4<T1, T2, T3, T4>(IterUtil.<Runnable4<? super T1, ? super T2, ? super T3, ? super T4>>
 732    make(r1, r2, r3));
 733    }
 734   
 735    /**
 736    * Create a runnable that executes the given runnables in sequence with the same input. The name {@code compose4}
 737    * is used to avoid a name clash with {@link #compose(Iterable)} (due to erasure).
 738    */
 739  0 public static <T1, T2, T3, T4> Runnable4<T1, T2, T3, T4>
 740    compose4(Iterable<? extends Runnable4<? super T1, ? super T2, ? super T3, ? super T4>> runnables) {
 741  0 return new ComposedRunnable4<T1, T2, T3, T4>(runnables);
 742    }
 743   
 744    private static final class ComposedRunnable4<T1, T2, T3, T4> implements Runnable4<T1, T2, T3, T4>, Serializable {
 745    private final Iterable<? extends Runnable4<? super T1, ? super T2, ? super T3, ? super T4>> _runnables;
 746  0 public
 747    ComposedRunnable4(Iterable<? extends Runnable4<? super T1, ? super T2, ? super T3, ? super T4>> runnables) {
 748  0 _runnables = runnables;
 749    }
 750  0 public void run(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 751  0 for (Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r : _runnables) {
 752  0 r.run(arg1, arg2, arg3, arg4);
 753    }
 754    }
 755    }
 756   
 757    /** Bind a fixed argument to the given lambda, producing a thunk. */
 758  2 public static <T, R> Thunk<R> bindFirst(Lambda<? super T, ? extends R> lambda, T arg) {
 759  2 return new BindFirstThunk<T, R>(lambda, arg);
 760    }
 761   
 762    private static final class BindFirstThunk<T, R> implements Thunk<R>, Serializable {
 763    private final Lambda<? super T, ? extends R> _lambda;
 764    private final T _arg;
 765  2 public BindFirstThunk(Lambda<? super T, ? extends R> lambda, T arg) { _lambda = lambda; _arg = arg; }
 766  2 public R value() { return _lambda.value(_arg); }
 767    }
 768   
 769    /** Bind a fixed argument to the given binary lambda, producing a unary lambda. */
 770  2 public static <T1, T2, R> Lambda<T2, R> bindFirst(Lambda2<? super T1, ? super T2, ? extends R> lambda, T1 arg1) {
 771  2 return new BindFirstLambda<T1, T2, R>(lambda, arg1);
 772    }
 773   
 774    private static final class BindFirstLambda<T1, T2, R> implements Lambda<T2, R>, Serializable {
 775    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 776    private final T1 _arg1;
 777  374 public BindFirstLambda(Lambda2<? super T1, ? super T2, ? extends R> lambda, T1 arg1) {
 778  374 _lambda = lambda; _arg1 = arg1;
 779    }
 780  185 public R value(T2 arg2) { return _lambda.value(_arg1, arg2); }
 781    }
 782   
 783    /** Bind a fixed argument to the given binary lambda, producing a unary lambda. */
 784  0 public static <T1, T2, R> Lambda<T1, R> bindSecond(Lambda2<? super T1, ? super T2, ? extends R> lambda, T2 arg2) {
 785  0 return new BindSecondLambda<T1, T2, R>(lambda, arg2);
 786    }
 787   
 788    private static final class BindSecondLambda<T1, T2, R> implements Lambda<T1, R>, Serializable {
 789    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 790    private final T2 _arg2;
 791  0 public BindSecondLambda(Lambda2<? super T1, ? super T2, ? extends R> lambda, T2 arg2) {
 792  0 _lambda = lambda; _arg2 = arg2;
 793    }
 794  0 public R value(T1 arg1) { return _lambda.value(arg1, _arg2); }
 795    }
 796   
 797    /** Bind a fixed argument to the given ternary lambda, producing a binary lambda. */
 798  1 public static <T1, T2, T3, R>
 799    Lambda2<T2, T3, R> bindFirst(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T1 arg1) {
 800  1 return new BindFirstLambda2<T1, T2, T3, R>(lambda, arg1);
 801    }
 802   
 803    private static final class BindFirstLambda2<T1, T2, T3, R> implements Lambda2<T2, T3, R>, Serializable {
 804    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 805    private final T1 _arg1;
 806  1 public BindFirstLambda2(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T1 arg1) {
 807  1 _lambda = lambda; _arg1 = arg1;
 808    }
 809  3 public R value(T2 arg2, T3 arg3) { return _lambda.value(_arg1, arg2, arg3); }
 810    }
 811   
 812    /** Bind a fixed argument to the given ternary lambda, producing a binary lambda. */
 813  0 public static <T1, T2, T3, R>
 814    Lambda2<T1, T3, R> bindSecond(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T2 arg2) {
 815  0 return new BindSecondLambda2<T1, T2, T3, R>(lambda, arg2);
 816    }
 817   
 818    private static final class BindSecondLambda2<T1, T2, T3, R> implements Lambda2<T1, T3, R>, Serializable {
 819    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 820    private final T2 _arg2;
 821  0 public BindSecondLambda2(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T2 arg2) {
 822  0 _lambda = lambda; _arg2 = arg2;
 823    }
 824  0 public R value(T1 arg1, T3 arg3) { return _lambda.value(arg1, _arg2, arg3); }
 825    }
 826   
 827    /** Bind a fixed argument to the given ternary lambda, producing a binary lambda. */
 828  0 public static <T1, T2, T3, R>
 829    Lambda2<T1, T2, R> bindThird(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T3 arg3) {
 830  0 return new BindThirdLambda2<T1, T2, T3, R>(lambda, arg3);
 831    }
 832   
 833    private static final class BindThirdLambda2<T1, T2, T3, R> implements Lambda2<T1, T2, R>, Serializable {
 834    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 835    private final T3 _arg3;
 836  0 public BindThirdLambda2(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, T3 arg3) {
 837  0 _lambda = lambda; _arg3 = arg3;
 838    }
 839  0 public R value(T1 arg1, T2 arg2) { return _lambda.value(arg1, arg2, _arg3); }
 840    }
 841   
 842    /** Bind a fixed argument to the given quaternary lambda, producing a ternary lambda. */
 843  1 public static <T1, T2, T3, T4, R> Lambda3<T2, T3, T4, R>
 844    bindFirst(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T1 arg1) {
 845  1 return new BindFirstLambda3<T1, T2, T3, T4, R>(lambda, arg1);
 846    }
 847   
 848    private static final class BindFirstLambda3<T1, T2, T3, T4, R> implements Lambda3<T2, T3, T4, R>, Serializable {
 849    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 850    private final T1 _arg1;
 851  1 public BindFirstLambda3(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T1 arg1) {
 852  1 _lambda = lambda; _arg1 = arg1;
 853    }
 854  3 public R value(T2 arg2, T3 arg3, T4 arg4) { return _lambda.value(_arg1, arg2, arg3, arg4); }
 855    }
 856   
 857    /** Bind a fixed argument to the given quaternary lambda, producing a ternary lambda. */
 858  0 public static <T1, T2, T3, T4, R> Lambda3<T1, T3, T4, R>
 859    bindSecond(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T2 arg2) {
 860  0 return new BindSecondLambda3<T1, T2, T3, T4, R>(lambda, arg2);
 861    }
 862   
 863    private static final class BindSecondLambda3<T1, T2, T3, T4, R> implements Lambda3<T1, T3, T4, R>, Serializable {
 864    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 865    private final T2 _arg2;
 866  0 public BindSecondLambda3(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T2 arg2) {
 867  0 _lambda = lambda; _arg2 = arg2;
 868    }
 869  0 public R value(T1 arg1, T3 arg3, T4 arg4) { return _lambda.value(arg1, _arg2, arg3, arg4); }
 870    }
 871   
 872    /** Bind a fixed argument to the given quaternary lambda, producing a ternary lambda. */
 873  0 public static <T1, T2, T3, T4, R> Lambda3<T1, T2, T4, R>
 874    bindThird(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T3 arg3) {
 875  0 return new BindThirdLambda3<T1, T2, T3, T4, R>(lambda, arg3);
 876    }
 877   
 878    private static final class BindThirdLambda3<T1, T2, T3, T4, R> implements Lambda3<T1, T2, T4, R>, Serializable {
 879    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 880    private final T3 _arg3;
 881  0 public BindThirdLambda3(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T3 arg3) {
 882  0 _lambda = lambda; _arg3 = arg3;
 883    }
 884  0 public R value(T1 arg1, T2 arg2, T4 arg4) { return _lambda.value(arg1, arg2, _arg3, arg4); }
 885    }
 886   
 887    /** Bind a fixed argument to the given quaternary lambda, producing a ternary lambda. */
 888  0 public static <T1, T2, T3, T4, R> Lambda3<T1, T2, T3, R>
 889    bindFourth(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T4 arg4) {
 890  0 return new BindFourthLambda3<T1, T2, T3, T4, R>(lambda, arg4);
 891    }
 892   
 893    private static final class BindFourthLambda3<T1, T2, T3, T4, R> implements Lambda3<T1, T2, T3, R>, Serializable {
 894    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 895    private final T4 _arg4;
 896  0 public BindFourthLambda3(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, T4 arg4) {
 897  0 _lambda = lambda; _arg4 = arg4;
 898    }
 899  0 public R value(T1 arg1, T2 arg2, T3 arg3) { return _lambda.value(arg1, arg2, arg3, _arg4); }
 900    }
 901   
 902   
 903    /** Bind a fixed argument to the given predicate, producing a condition. */
 904  0 public static <T> Condition bindFirst(Predicate<? super T> pred, T arg) {
 905  0 return new BindFirstCondition<T>(pred, arg);
 906    }
 907   
 908    private static final class BindFirstCondition<T> implements Condition, Serializable {
 909    private final Predicate<? super T> _pred;
 910    private final T _arg;
 911  0 public BindFirstCondition(Predicate<? super T> pred, T arg) { _pred = pred; _arg = arg; }
 912  0 public boolean isTrue() { return _pred.contains(_arg); }
 913    }
 914   
 915    /** Bind a fixed argument to the given binary predicate, producing a unary prediate. */
 916  86 public static <T1, T2> Predicate<T2> bindFirst(Predicate2<? super T1, ? super T2> pred, T1 arg1) {
 917  86 return new BindFirstPredicate<T1, T2>(pred, arg1);
 918    }
 919   
 920    private static final class BindFirstPredicate<T1, T2> implements Predicate<T2>, Serializable {
 921    private final Predicate2<? super T1, ? super T2> _pred;
 922    private final T1 _arg1;
 923  86 public BindFirstPredicate(Predicate2<? super T1, ? super T2> pred, T1 arg1) {
 924  86 _pred = pred; _arg1 = arg1;
 925    }
 926  94 public boolean contains(T2 arg2) { return _pred.contains(_arg1, arg2); }
 927    }
 928   
 929    /** Bind a fixed argument to the given binary predicate, producing a unary predicate. */
 930  0 public static <T1, T2> Predicate<T1> bindSecond(Predicate2<? super T1, ? super T2> pred, T2 arg2) {
 931  0 return new BindSecondPredicate<T1, T2>(pred, arg2);
 932    }
 933   
 934    private static final class BindSecondPredicate<T1, T2> implements Predicate<T1>, Serializable {
 935    private final Predicate2<? super T1, ? super T2> _pred;
 936    private final T2 _arg2;
 937  0 public BindSecondPredicate(Predicate2<? super T1, ? super T2> pred, T2 arg2) {
 938  0 _pred = pred; _arg2 = arg2;
 939    }
 940  0 public boolean contains(T1 arg1) { return _pred.contains(arg1, _arg2); }
 941    }
 942   
 943    /** Bind a fixed argument to the given ternary predicate, producing a binary predicate. */
 944  0 public static <T1, T2, T3>
 945    Predicate2<T2, T3> bindFirst(Predicate3<? super T1, ? super T2, ? super T3> pred, T1 arg1) {
 946  0 return new BindFirstPredicate2<T1, T2, T3>(pred, arg1);
 947    }
 948   
 949    private static final class BindFirstPredicate2<T1, T2, T3> implements Predicate2<T2, T3>, Serializable {
 950    private final Predicate3<? super T1, ? super T2, ? super T3> _pred;
 951    private final T1 _arg1;
 952  0 public BindFirstPredicate2(Predicate3<? super T1, ? super T2, ? super T3> pred, T1 arg1) {
 953  0 _pred = pred; _arg1 = arg1;
 954    }
 955  0 public boolean contains(T2 arg2, T3 arg3) { return _pred.contains(_arg1, arg2, arg3); }
 956    }
 957   
 958    /** Bind a fixed argument to the given ternary predicate, producing a binary predicate. */
 959  0 public static <T1, T2, T3>
 960    Predicate2<T1, T3> bindSecond(Predicate3<? super T1, ? super T2, ? super T3> pred, T2 arg2) {
 961  0 return new BindSecondPredicate2<T1, T2, T3>(pred, arg2);
 962    }
 963   
 964    private static final class BindSecondPredicate2<T1, T2, T3> implements Predicate2<T1, T3>, Serializable {
 965    private final Predicate3<? super T1, ? super T2, ? super T3> _pred;
 966    private final T2 _arg2;
 967  0 public BindSecondPredicate2(Predicate3<? super T1, ? super T2, ? super T3> pred, T2 arg2) {
 968  0 _pred = pred; _arg2 = arg2;
 969    }
 970  0 public boolean contains(T1 arg1, T3 arg3) { return _pred.contains(arg1, _arg2, arg3); }
 971    }
 972   
 973    /** Bind a fixed argument to the given ternary predicate, producing a binary predicate. */
 974  0 public static <T1, T2, T3>
 975    Predicate2<T1, T2> bindThird(Predicate3<? super T1, ? super T2, ? super T3> pred, T3 arg3) {
 976  0 return new BindThirdPredicate2<T1, T2, T3>(pred, arg3);
 977    }
 978   
 979    private static final class BindThirdPredicate2<T1, T2, T3> implements Predicate2<T1, T2>, Serializable {
 980    private final Predicate3<? super T1, ? super T2, ? super T3> _pred;
 981    private final T3 _arg3;
 982  0 public BindThirdPredicate2(Predicate3<? super T1, ? super T2, ? super T3> pred, T3 arg3) {
 983  0 _pred = pred; _arg3 = arg3;
 984    }
 985  0 public boolean contains(T1 arg1, T2 arg2) { return _pred.contains(arg1, arg2, _arg3); }
 986    }
 987   
 988    /** Bind a fixed argument to the given quaternary predicate, producing a ternary predicate. */
 989  0 public static <T1, T2, T3, T4> Predicate3<T2, T3, T4>
 990    bindFirst(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T1 arg1) {
 991  0 return new BindFirstPredicate3<T1, T2, T3, T4>(pred, arg1);
 992    }
 993   
 994    private static final class BindFirstPredicate3<T1, T2, T3, T4> implements Predicate3<T2, T3, T4>, Serializable {
 995    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _pred;
 996    private final T1 _arg1;
 997  0 public BindFirstPredicate3(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T1 arg1) {
 998  0 _pred = pred; _arg1 = arg1;
 999    }
 1000  0 public boolean contains(T2 arg2, T3 arg3, T4 arg4) { return _pred.contains(_arg1, arg2, arg3, arg4); }
 1001    }
 1002   
 1003    /** Bind a fixed argument to the given quaternary predicate, producing a ternary predicate. */
 1004  0 public static <T1, T2, T3, T4> Predicate3<T1, T3, T4>
 1005    bindSecond(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T2 arg2) {
 1006  0 return new BindSecondPredicate3<T1, T2, T3, T4>(pred, arg2);
 1007    }
 1008   
 1009    private static final class BindSecondPredicate3<T1, T2, T3, T4> implements Predicate3<T1, T3, T4>, Serializable {
 1010    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _pred;
 1011    private final T2 _arg2;
 1012  0 public BindSecondPredicate3(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T2 arg2) {
 1013  0 _pred = pred; _arg2 = arg2;
 1014    }
 1015  0 public boolean contains(T1 arg1, T3 arg3, T4 arg4) { return _pred.contains(arg1, _arg2, arg3, arg4); }
 1016    }
 1017   
 1018    /** Bind a fixed argument to the given quaternary predicate, producing a ternary predicate. */
 1019  0 public static <T1, T2, T3, T4> Predicate3<T1, T2, T4>
 1020    bindThird(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T3 arg3) {
 1021  0 return new BindThirdPredicate3<T1, T2, T3, T4>(pred, arg3);
 1022    }
 1023   
 1024    private static final class BindThirdPredicate3<T1, T2, T3, T4> implements Predicate3<T1, T2, T4>, Serializable {
 1025    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _pred;
 1026    private final T3 _arg3;
 1027  0 public BindThirdPredicate3(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T3 arg3) {
 1028  0 _pred = pred; _arg3 = arg3;
 1029    }
 1030  0 public boolean contains(T1 arg1, T2 arg2, T4 arg4) { return _pred.contains(arg1, arg2, _arg3, arg4); }
 1031    }
 1032   
 1033    /** Bind a fixed argument to the given quaternary pred, producing a ternary pred. */
 1034  0 public static <T1, T2, T3, T4> Predicate3<T1, T2, T3>
 1035    bindFourth(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T4 arg4) {
 1036  0 return new BindFourthPredicate3<T1, T2, T3, T4>(pred, arg4);
 1037    }
 1038   
 1039    private static final class BindFourthPredicate3<T1, T2, T3, T4> implements Predicate3<T1, T2, T3>, Serializable {
 1040    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _pred;
 1041    private final T4 _arg4;
 1042  0 public BindFourthPredicate3(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred, T4 arg4) {
 1043  0 _pred = pred; _arg4 = arg4;
 1044    }
 1045  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) { return _pred.contains(arg1, arg2, arg3, _arg4); }
 1046    }
 1047   
 1048   
 1049    /** Bind a fixed argument to the given unary runnable, producing nullary runnable. */
 1050  0 public static <T> Runnable bindFirst(Runnable1<? super T> runnable, T arg) {
 1051  0 return new BindFirstRunnable<T>(runnable, arg);
 1052    }
 1053   
 1054    private static final class BindFirstRunnable<T> implements Runnable, Serializable {
 1055    private final Runnable1<? super T> _runnable;
 1056    private final T _arg;
 1057  0 public BindFirstRunnable(Runnable1<? super T> runnable, T arg) { _runnable = runnable; _arg = arg; }
 1058  0 public void run() { _runnable.run(_arg); }
 1059    }
 1060   
 1061    /** Bind a fixed argument to the given binary runnable, producing a unary runnable. */
 1062  0 public static <T1, T2> Runnable1<T2> bindFirst(Runnable2<? super T1, ? super T2> runnable, T1 arg1) {
 1063  0 return new BindFirstRunnable1<T1, T2>(runnable, arg1);
 1064    }
 1065   
 1066    private static final class BindFirstRunnable1<T1, T2> implements Runnable1<T2>, Serializable {
 1067    private final Runnable2<? super T1, ? super T2> _runnable;
 1068    private final T1 _arg1;
 1069  0 public BindFirstRunnable1(Runnable2<? super T1, ? super T2> runnable, T1 arg1) {
 1070  0 _runnable = runnable; _arg1 = arg1;
 1071    }
 1072  0 public void run(T2 arg2) { _runnable.run(_arg1, arg2); }
 1073    }
 1074   
 1075    /** Bind a fixed argument to the given binary runnable, producing a unary runnable. */
 1076  0 public static <T1, T2> Runnable1<T1> bindSecond(Runnable2<? super T1, ? super T2> runnable, T2 arg2) {
 1077  0 return new BindSecondRunnable1<T1, T2>(runnable, arg2);
 1078    }
 1079   
 1080    private static final class BindSecondRunnable1<T1, T2> implements Runnable1<T1>, Serializable {
 1081    private final Runnable2<? super T1, ? super T2> _runnable;
 1082    private final T2 _arg2;
 1083  0 public BindSecondRunnable1(Runnable2<? super T1, ? super T2> runnable, T2 arg2) {
 1084  0 _runnable = runnable; _arg2 = arg2;
 1085    }
 1086  0 public void run(T1 arg1) { _runnable.run(arg1, _arg2); }
 1087    }
 1088   
 1089    /** Bind a fixed argument to the given ternary runnable, producing a binary runnable. */
 1090  0 public static <T1, T2, T3>
 1091    Runnable2<T2, T3> bindFirst(Runnable3<? super T1, ? super T2, ? super T3> runnable, T1 arg1) {
 1092  0 return new BindFirstRunnable2<T1, T2, T3>(runnable, arg1);
 1093    }
 1094   
 1095    private static final class BindFirstRunnable2<T1, T2, T3> implements Runnable2<T2, T3>, Serializable {
 1096    private final Runnable3<? super T1, ? super T2, ? super T3> _runnable;
 1097    private final T1 _arg1;
 1098  0 public BindFirstRunnable2(Runnable3<? super T1, ? super T2, ? super T3> runnable, T1 arg1) {
 1099  0 _runnable = runnable; _arg1 = arg1;
 1100    }
 1101  0 public void run(T2 arg2, T3 arg3) { _runnable.run(_arg1, arg2, arg3); }
 1102    }
 1103   
 1104    /** Bind a fixed argument to the given ternary runnable, producing a binary runnable. */
 1105  0 public static <T1, T2, T3>
 1106    Runnable2<T1, T3> bindSecond(Runnable3<? super T1, ? super T2, ? super T3> runnable, T2 arg2) {
 1107  0 return new BindSecondRunnable2<T1, T2, T3>(runnable, arg2);
 1108    }
 1109   
 1110    private static final class BindSecondRunnable2<T1, T2, T3> implements Runnable2<T1, T3>, Serializable {
 1111    private final Runnable3<? super T1, ? super T2, ? super T3> _runnable;
 1112    private final T2 _arg2;
 1113  0 public BindSecondRunnable2(Runnable3<? super T1, ? super T2, ? super T3> runnable, T2 arg2) {
 1114  0 _runnable = runnable; _arg2 = arg2;
 1115    }
 1116  0 public void run(T1 arg1, T3 arg3) { _runnable.run(arg1, _arg2, arg3); }
 1117    }
 1118   
 1119    /** Bind a fixed argument to the given ternary runnable, producing a binary runnable. */
 1120  0 public static <T1, T2, T3>
 1121    Runnable2<T1, T2> bindThird(Runnable3<? super T1, ? super T2, ? super T3> runnable, T3 arg3) {
 1122  0 return new BindThirdRunnable2<T1, T2, T3>(runnable, arg3);
 1123    }
 1124   
 1125    private static final class BindThirdRunnable2<T1, T2, T3> implements Runnable2<T1, T2>, Serializable {
 1126    private final Runnable3<? super T1, ? super T2, ? super T3> _runnable;
 1127    private final T3 _arg3;
 1128  0 public BindThirdRunnable2(Runnable3<? super T1, ? super T2, ? super T3> runnable, T3 arg3) {
 1129  0 _runnable = runnable; _arg3 = arg3;
 1130    }
 1131  0 public void run(T1 arg1, T2 arg2) { _runnable.run(arg1, arg2, _arg3); }
 1132    }
 1133   
 1134    /** Bind a fixed argument to the given quaternary runnable, producing a ternary runnable. */
 1135  0 public static <T1, T2, T3, T4> Runnable3<T2, T3, T4>
 1136    bindFirst(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T1 arg1) {
 1137  0 return new BindFirstRunnable3<T1, T2, T3, T4>(runnable, arg1);
 1138    }
 1139   
 1140    private static final class BindFirstRunnable3<T1, T2, T3, T4> implements Runnable3<T2, T3, T4>, Serializable {
 1141    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _runnable;
 1142    private final T1 _arg1;
 1143  0 public BindFirstRunnable3(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T1 arg1) {
 1144  0 _runnable = runnable; _arg1 = arg1;
 1145    }
 1146  0 public void run(T2 arg2, T3 arg3, T4 arg4) { _runnable.run(_arg1, arg2, arg3, arg4); }
 1147    }
 1148   
 1149    /** Bind a fixed argument to the given quaternary runnable, producing a ternary runnable. */
 1150  0 public static <T1, T2, T3, T4> Runnable3<T1, T3, T4>
 1151    bindSecond(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T2 arg2) {
 1152  0 return new BindSecondRunnable3<T1, T2, T3, T4>(runnable, arg2);
 1153    }
 1154   
 1155    private static final class BindSecondRunnable3<T1, T2, T3, T4> implements Runnable3<T1, T3, T4>, Serializable {
 1156    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _runnable;
 1157    private final T2 _arg2;
 1158  0 public BindSecondRunnable3(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T2 arg2) {
 1159  0 _runnable = runnable; _arg2 = arg2;
 1160    }
 1161  0 public void run(T1 arg1, T3 arg3, T4 arg4) { _runnable.run(arg1, _arg2, arg3, arg4); }
 1162    }
 1163   
 1164    /** Bind a fixed argument to the given quaternary runnable, producing a ternary runnable. */
 1165  0 public static <T1, T2, T3, T4> Runnable3<T1, T2, T4>
 1166    bindThird(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T3 arg3) {
 1167  0 return new BindThirdRunnable3<T1, T2, T3, T4>(runnable, arg3);
 1168    }
 1169   
 1170    private static final class BindThirdRunnable3<T1, T2, T3, T4> implements Runnable3<T1, T2, T4>, Serializable {
 1171    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _runnable;
 1172    private final T3 _arg3;
 1173  0 public BindThirdRunnable3(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T3 arg3) {
 1174  0 _runnable = runnable; _arg3 = arg3;
 1175    }
 1176  0 public void run(T1 arg1, T2 arg2, T4 arg4) { _runnable.run(arg1, arg2, _arg3, arg4); }
 1177    }
 1178   
 1179    /** Bind a fixed argument to the given quaternary runnable, producing a ternary runnable. */
 1180  0 public static <T1, T2, T3, T4> Runnable3<T1, T2, T3>
 1181    bindFourth(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T4 arg4) {
 1182  0 return new BindFourthRunnable3<T1, T2, T3, T4>(runnable, arg4);
 1183    }
 1184   
 1185    private static final class BindFourthRunnable3<T1, T2, T3, T4> implements Runnable3<T1, T2, T3>, Serializable {
 1186    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _runnable;
 1187    private final T4 _arg4;
 1188  0 public BindFourthRunnable3(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable, T4 arg4) {
 1189  0 _runnable = runnable; _arg4 = arg4;
 1190    }
 1191  0 public void run(T1 arg1, T2 arg2, T3 arg3) { _runnable.run(arg1, arg2, arg3, _arg4); }
 1192    }
 1193   
 1194   
 1195    /**
 1196    * Create a curried version of the input, which accepts a single argument and returns a lambda on the second
 1197    * argument.
 1198    */
 1199  24 public static <T1, T2, R> Lambda<T1, Lambda<T2, R>> curry(Lambda2<? super T1, ? super T2, ? extends R> lambda) {
 1200  24 return new CurriedLambda2<T1, T2, R>(lambda);
 1201    }
 1202   
 1203    private static final class CurriedLambda2<T1, T2, R> implements Lambda<T1, Lambda<T2, R>>, Serializable {
 1204    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 1205  24 public CurriedLambda2(Lambda2<? super T1, ? super T2, ? extends R> lambda) { _lambda = lambda; }
 1206  372 public Lambda<T2, R> value(T1 arg) { return new BindFirstLambda<T1, T2, R>(_lambda, arg); }
 1207    }
 1208   
 1209    /**
 1210    * Create a curried version of the input, which accepts a single argument and returns a curried lambda on the
 1211    * other arguments.
 1212    */
 1213  0 public static <T1, T2, T3, R>
 1214    Lambda<T1, Lambda<T2, Lambda<T3, R>>> curry(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) {
 1215  0 return new CurriedLambda3<T1, T2, T3, R>(lambda);
 1216    }
 1217   
 1218    private static final class CurriedLambda3<T1, T2, T3, R>
 1219    implements Lambda<T1, Lambda<T2, Lambda<T3, R>>>, Serializable {
 1220    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 1221  0 public CurriedLambda3(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) { _lambda = lambda; }
 1222  0 public Lambda<T2, Lambda<T3, R>> value(T1 arg) {
 1223  0 return new CurriedLambda2<T2, T3, R>(new BindFirstLambda2<T1, T2, T3, R>(_lambda, arg));
 1224    }
 1225    }
 1226   
 1227    /**
 1228    * Create a curried version of the input, which accepts a single argument and returns a curried lambda on the
 1229    * other arguments.
 1230    */
 1231  0 public static <T1, T2, T3, T4, R> Lambda<T1, Lambda<T2, Lambda<T3, Lambda<T4, R>>>>
 1232    curry(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1233  0 return new CurriedLambda4<T1, T2, T3, T4, R>(lambda);
 1234    }
 1235   
 1236    private static final class CurriedLambda4<T1, T2, T3, T4, R>
 1237    implements Lambda<T1, Lambda<T2, Lambda<T3, Lambda<T4, R>>>>, Serializable {
 1238    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 1239  0 public CurriedLambda4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1240  0 _lambda = lambda;
 1241    }
 1242  0 public Lambda<T2, Lambda<T3, Lambda<T4, R>>> value(T1 arg) {
 1243  0 return new CurriedLambda3<T2, T3, T4, R>(new BindFirstLambda3<T1, T2, T3, T4, R>(_lambda, arg));
 1244    }
 1245    }
 1246   
 1247    /** Swap the order of a binary lambda's arguments. */
 1248  0 public static <T1, T2, R> Lambda2<T2, T1, R> transpose(Lambda2<? super T1, ? super T2, ? extends R> lambda) {
 1249  0 return new TransposedLambda2<T1, T2, R>(lambda);
 1250    }
 1251   
 1252    private static final class TransposedLambda2<T1, T2, R> implements Lambda2<T2, T1, R>, Serializable {
 1253    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 1254  0 public TransposedLambda2(Lambda2<? super T1, ? super T2, ? extends R> lambda) { _lambda = lambda; }
 1255  0 public R value(T2 arg2, T1 arg1) { return _lambda.value(arg1, arg2); }
 1256    }
 1257   
 1258    /** Swap the order of a binary predicate's arguments. */
 1259  0 public static <T1, T2> Predicate2<T2, T1> transpose(Predicate2<? super T1, ? super T2> pred) {
 1260  0 return new TransposedPredicate2<T1, T2>(pred);
 1261    }
 1262   
 1263    private static final class TransposedPredicate2<T1, T2> implements Predicate2<T2, T1>, Serializable {
 1264    private final Predicate2<? super T1, ? super T2> _pred;
 1265  0 public TransposedPredicate2(Predicate2<? super T1, ? super T2> pred) { _pred = pred; }
 1266  0 public boolean contains(T2 arg2, T1 arg1) { return _pred.contains(arg1, arg2); }
 1267    }
 1268   
 1269    /** Swap the order of a binary runnable's arguments. */
 1270  0 public static <T1, T2> Runnable2<T2, T1> transpose(Runnable2<? super T1, ? super T2> r) {
 1271  0 return new TransposedRunnable2<T1, T2>(r);
 1272    }
 1273   
 1274    private static final class TransposedRunnable2<T1, T2> implements Runnable2<T2, T1>, Serializable {
 1275    private final Runnable2<? super T1, ? super T2> _r;
 1276  0 public TransposedRunnable2(Runnable2<? super T1, ? super T2> r) { _r = r; }
 1277  0 public void run(T2 arg2, T1 arg1) { _r.run(arg1, arg2); }
 1278    }
 1279   
 1280    /** Treat a lambda accepting a 0-tuple argument as a Thunk. */
 1281  0 public static <T, R> Thunk<R> flatten0(Lambda<? super Null<T>, ? extends R> lambda) {
 1282  0 return new BindFirstThunk<Null<T>, R>(lambda, Null.<T>make());
 1283    }
 1284   
 1285    /** Treat a lambda accepting a Pair argument as a Lambda2. */
 1286  0 public static <T1, T2, R> Lambda2<T1, T2, R> flatten2(Lambda<? super Pair<T1, T2>, ? extends R> lambda) {
 1287  0 return new FlattenedLambda2<T1, T2, R>(lambda);
 1288    }
 1289   
 1290    private static final class FlattenedLambda2<T1, T2, R> implements Lambda2<T1, T2, R>, Serializable {
 1291    private final Lambda<? super Pair<T1, T2>, ? extends R> _lambda;
 1292  0 public FlattenedLambda2(Lambda<? super Pair<T1, T2>, ? extends R> lambda) { _lambda = lambda; }
 1293  0 public R value(T1 arg1, T2 arg2) { return _lambda.value(new Pair<T1, T2>(arg1, arg2)); }
 1294    }
 1295   
 1296    /** Treat a lambda accepting a Triple argument as a Lambda3. */
 1297  0 public static <T1, T2, T3, R>
 1298    Lambda3<T1, T2, T3, R> flatten3(Lambda<? super Triple<T1, T2, T3>, ? extends R> lambda) {
 1299  0 return new FlattenedLambda3<T1, T2, T3, R>(lambda);
 1300    }
 1301   
 1302    private static final class FlattenedLambda3<T1, T2, T3, R> implements Lambda3<T1, T2, T3, R>, Serializable {
 1303    private final Lambda<? super Triple<T1, T2, T3>, ? extends R> _lambda;
 1304  0 public FlattenedLambda3(Lambda<? super Triple<T1, T2, T3>, ? extends R> lambda) { _lambda = lambda; }
 1305  0 public R value(T1 arg1, T2 arg2, T3 arg3) {
 1306  0 return _lambda.value(new Triple<T1, T2, T3>(arg1, arg2, arg3));
 1307    }
 1308    }
 1309   
 1310    /** Treat a lambda accepting a Quad argument as a Lambda4. */
 1311  0 public static <T1, T2, T3, T4, R>
 1312    Lambda4<T1, T2, T3, T4, R> flatten4(Lambda<? super Quad<T1, T2, T3, T4>, ? extends R> lambda) {
 1313  0 return new FlattenedLambda4<T1, T2, T3, T4, R>(lambda);
 1314    }
 1315   
 1316    private static final class FlattenedLambda4<T1, T2, T3, T4, R>
 1317    implements Lambda4<T1, T2, T3, T4, R>, Serializable {
 1318    private final Lambda<? super Quad<T1, T2, T3, T4>, ? extends R> _lambda;
 1319  0 public FlattenedLambda4(Lambda<? super Quad<T1, T2, T3, T4>, ? extends R> lambda) { _lambda = lambda; }
 1320  0 public R value(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 1321  0 return _lambda.value(new Quad<T1, T2, T3, T4>(arg1, arg2, arg3, arg4));
 1322    }
 1323    }
 1324   
 1325    /** Treat a predicate accepting a 0-tuple argument as a Condition. */
 1326  0 public static <T> Condition flatten0(Predicate<? super Null<T>> pred) {
 1327  0 return new BindFirstCondition<Null<T>>(pred, Null.<T>make());
 1328    }
 1329   
 1330    /** Treat a predicate accepting a Pair argument as a Predicate2. */
 1331  0 public static <T1, T2> Predicate2<T1, T2> flatten2(Predicate<? super Pair<T1, T2>> pred) {
 1332  0 return new FlattenedPredicate2<T1, T2>(pred);
 1333    }
 1334   
 1335    private static final class FlattenedPredicate2<T1, T2> implements Predicate2<T1, T2>, Serializable {
 1336    private final Predicate<? super Pair<T1, T2>> _pred;
 1337  0 public FlattenedPredicate2(Predicate<? super Pair<T1, T2>> pred) { _pred = pred; }
 1338  0 public boolean contains(T1 arg1, T2 arg2) { return _pred.contains(new Pair<T1, T2>(arg1, arg2)); }
 1339    }
 1340   
 1341    /** Treat a predicate accepting a Triple argument as a Predicate3. */
 1342  0 public static <T1, T2, T3>
 1343    Predicate3<T1, T2, T3> flatten3(Predicate<? super Triple<T1, T2, T3>> pred) {
 1344  0 return new FlattenedPredicate3<T1, T2, T3>(pred);
 1345    }
 1346   
 1347    private static final class FlattenedPredicate3<T1, T2, T3> implements Predicate3<T1, T2, T3>, Serializable {
 1348    private final Predicate<? super Triple<T1, T2, T3>> _pred;
 1349  0 public FlattenedPredicate3(Predicate<? super Triple<T1, T2, T3>> pred) { _pred = pred; }
 1350  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) {
 1351  0 return _pred.contains(new Triple<T1, T2, T3>(arg1, arg2, arg3));
 1352    }
 1353    }
 1354   
 1355    /** Treat a predicate accepting a Quad argument as a Predicate4. */
 1356  0 public static <T1, T2, T3, T4>
 1357    Predicate4<T1, T2, T3, T4> flatten4(Predicate<? super Quad<T1, T2, T3, T4>> pred) {
 1358  0 return new FlattenedPredicate4<T1, T2, T3, T4>(pred);
 1359    }
 1360   
 1361    private static final class FlattenedPredicate4<T1, T2, T3, T4>
 1362    implements Predicate4<T1, T2, T3, T4>, Serializable {
 1363    private final Predicate<? super Quad<T1, T2, T3, T4>> _pred;
 1364  0 public FlattenedPredicate4(Predicate<? super Quad<T1, T2, T3, T4>> pred) { _pred = pred; }
 1365  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 1366  0 return _pred.contains(new Quad<T1, T2, T3, T4>(arg1, arg2, arg3, arg4));
 1367    }
 1368    }
 1369   
 1370    /** Treat a runnable accepting a 0-tuple argument as a Runnable. */
 1371  0 public static <T> Runnable flatten0(Runnable1<? super Null<T>> runnable) {
 1372  0 return new BindFirstRunnable<Null<T>>(runnable, Null.<T>make());
 1373    }
 1374   
 1375    /** Treat a runnable accepting a Pair argument as a Runnable2. */
 1376  0 public static <T1, T2> Runnable2<T1, T2> flatten2(Runnable1<? super Pair<T1, T2>> runnable) {
 1377  0 return new FlattenedRunnable2<T1, T2>(runnable);
 1378    }
 1379   
 1380    private static final class FlattenedRunnable2<T1, T2> implements Runnable2<T1, T2>, Serializable {
 1381    private final Runnable1<? super Pair<T1, T2>> _runnable;
 1382  0 public FlattenedRunnable2(Runnable1<? super Pair<T1, T2>> runnable) { _runnable = runnable; }
 1383  0 public void run(T1 arg1, T2 arg2) { _runnable.run(new Pair<T1, T2>(arg1, arg2)); }
 1384    }
 1385   
 1386    /** Treat a runnable accepting a Triple argument as a Runnable3. */
 1387  0 public static <T1, T2, T3>
 1388    Runnable3<T1, T2, T3> flatten3(Runnable1<? super Triple<T1, T2, T3>> runnable) {
 1389  0 return new FlattenedRunnable3<T1, T2, T3>(runnable);
 1390    }
 1391   
 1392    private static final class FlattenedRunnable3<T1, T2, T3> implements Runnable3<T1, T2, T3>, Serializable {
 1393    private final Runnable1<? super Triple<T1, T2, T3>> _runnable;
 1394  0 public FlattenedRunnable3(Runnable1<? super Triple<T1, T2, T3>> runnable) { _runnable = runnable; }
 1395  0 public void run(T1 arg1, T2 arg2, T3 arg3) {
 1396  0 _runnable.run(new Triple<T1, T2, T3>(arg1, arg2, arg3));
 1397    }
 1398    }
 1399   
 1400    /** Treat a runnable accepting a Quad argument as a Runnable4. */
 1401  0 public static <T1, T2, T3, T4>
 1402    Runnable4<T1, T2, T3, T4> flatten4(Runnable1<? super Quad<T1, T2, T3, T4>> runnable) {
 1403  0 return new FlattenedRunnable4<T1, T2, T3, T4>(runnable);
 1404    }
 1405   
 1406    private static final class FlattenedRunnable4<T1, T2, T3, T4>
 1407    implements Runnable4<T1, T2, T3, T4>, Serializable {
 1408    private final Runnable1<? super Quad<T1, T2, T3, T4>> _runnable;
 1409  0 public FlattenedRunnable4(Runnable1<? super Quad<T1, T2, T3, T4>> runnable) { _runnable = runnable; }
 1410  0 public void run(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 1411  0 _runnable.run(new Quad<T1, T2, T3, T4>(arg1, arg2, arg3, arg4));
 1412    }
 1413    }
 1414   
 1415    /** Treat a Thunk as a unary lambda accepting a 0-tuple argument. */
 1416  0 public static <R> Lambda<Null<?>, R> unary(Thunk<? extends R> thunk) {
 1417  0 return new UnaryThunk<R>(thunk);
 1418    }
 1419   
 1420    private static final class UnaryThunk<R> implements Lambda<Null<?>, R>, Serializable {
 1421    private final Thunk<? extends R> _thunk;
 1422  0 public UnaryThunk(Thunk<? extends R> thunk) { _thunk = thunk; }
 1423  0 public R value(Null<?> arg) { return _thunk.value(); }
 1424    }
 1425   
 1426    /** Treat a Lambda2 as a unary lambda accepting a Pair argument. */
 1427  0 public static <T1, T2, R> Lambda<Pair<T1, T2>, R>
 1428    unary(Lambda2<? super T1, ? super T2, ? extends R> lambda) {
 1429  0 return new UnaryLambda2<T1, T2, R>(lambda);
 1430    }
 1431   
 1432    private static final class UnaryLambda2<T1, T2, R> implements Lambda<Pair<T1, T2>, R>, Serializable {
 1433    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 1434  0 public UnaryLambda2(Lambda2<? super T1, ? super T2, ? extends R> lambda) { _lambda = lambda; }
 1435  0 public R value(Pair<T1, T2> arg) { return _lambda.value(arg.first(), arg.second()); }
 1436    }
 1437   
 1438    /** Treat a Lambda3 as a unary lambda accepting a Triple argument. */
 1439  0 public static <T1, T2, T3, R> Lambda<Triple<T1, T2, T3>, R>
 1440    unary(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) {
 1441  0 return new UnaryLambda3<T1, T2, T3, R>(lambda);
 1442    }
 1443   
 1444    private static final class UnaryLambda3<T1, T2, T3, R>
 1445    implements Lambda<Triple<T1, T2, T3>, R>, Serializable {
 1446    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 1447  0 public UnaryLambda3(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) {
 1448  0 _lambda = lambda;
 1449    }
 1450  0 public R value(Triple<T1, T2, T3> arg) {
 1451  0 return _lambda.value(arg.first(), arg.second(), arg.third());
 1452    }
 1453    }
 1454   
 1455    /** Treat a Lambda4 as a unary lambda accepting a Quad argument. */
 1456  0 public static <T1, T2, T3, T4, R> Lambda<Quad<T1, T2, T3, T4>, R>
 1457    unary(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1458  0 return new UnaryLambda4<T1, T2, T3, T4, R>(lambda);
 1459    }
 1460   
 1461    private static final class UnaryLambda4<T1, T2, T3, T4, R>
 1462    implements Lambda<Quad<T1, T2, T3, T4>, R>, Serializable {
 1463    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 1464  0 public UnaryLambda4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1465  0 _lambda = lambda;
 1466    }
 1467  0 public R value(Quad<T1, T2, T3, T4> arg) {
 1468  0 return _lambda.value(arg.first(), arg.second(), arg.third(), arg.fourth());
 1469    }
 1470    }
 1471   
 1472    /** Treat a Condition as a unary predicate accepting a 0-tuple argument. */
 1473  0 public static Predicate<Null<?>> unary(Condition cond) {
 1474  0 return new UnaryCondition(cond);
 1475    }
 1476   
 1477    private static final class UnaryCondition implements Predicate<Null<?>>, Serializable {
 1478    private final Condition _cond;
 1479  0 public UnaryCondition(Condition cond) { _cond = cond; }
 1480  0 public boolean contains(Null<?> arg) { return _cond.isTrue(); }
 1481    }
 1482   
 1483    /** Treat a Predicate2 as a unary predicate accepting a Pair argument. */
 1484  0 public static <T1, T2> Predicate<Pair<T1, T2>>
 1485    unary(Predicate2<? super T1, ? super T2> pred) {
 1486  0 return new UnaryPredicate2<T1, T2>(pred);
 1487    }
 1488   
 1489    private static final class UnaryPredicate2<T1, T2> implements Predicate<Pair<T1, T2>>, Serializable {
 1490    private final Predicate2<? super T1, ? super T2> _pred;
 1491  0 public UnaryPredicate2(Predicate2<? super T1, ? super T2> pred) { _pred = pred; }
 1492  0 public boolean contains(Pair<T1, T2> arg) { return _pred.contains(arg.first(), arg.second()); }
 1493    }
 1494   
 1495    /** Treat a Predicate3 as a unary predicate accepting a Triple argument. */
 1496  0 public static <T1, T2, T3> Predicate<Triple<T1, T2, T3>>
 1497    unary(Predicate3<? super T1, ? super T2, ? super T3> pred) {
 1498  0 return new UnaryPredicate3<T1, T2, T3>(pred);
 1499    }
 1500   
 1501    private static final class UnaryPredicate3<T1, T2, T3>
 1502    implements Predicate<Triple<T1, T2, T3>>, Serializable {
 1503    private final Predicate3<? super T1, ? super T2, ? super T3> _pred;
 1504  0 public UnaryPredicate3(Predicate3<? super T1, ? super T2, ? super T3> pred) {
 1505  0 _pred = pred;
 1506    }
 1507  0 public boolean contains(Triple<T1, T2, T3> arg) {
 1508  0 return _pred.contains(arg.first(), arg.second(), arg.third());
 1509    }
 1510    }
 1511   
 1512    /** Treat a Predicate4 as a unary predicate accepting a Quad argument. */
 1513  0 public static <T1, T2, T3, T4> Predicate<Quad<T1, T2, T3, T4>>
 1514    unary(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred) {
 1515  0 return new UnaryPredicate4<T1, T2, T3, T4>(pred);
 1516    }
 1517   
 1518    private static final class UnaryPredicate4<T1, T2, T3, T4>
 1519    implements Predicate<Quad<T1, T2, T3, T4>>, Serializable {
 1520    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _pred;
 1521  0 public UnaryPredicate4(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred) {
 1522  0 _pred = pred;
 1523    }
 1524  0 public boolean contains(Quad<T1, T2, T3, T4> arg) {
 1525  0 return _pred.contains(arg.first(), arg.second(), arg.third(), arg.fourth());
 1526    }
 1527    }
 1528   
 1529    /** Treat a Runnable as a Runnable1 accepting a 0-tuple argument. */
 1530  0 public static Runnable1<Null<?>> unary(Runnable runnable) {
 1531  0 return new UnaryRunnable(runnable);
 1532    }
 1533   
 1534    private static final class UnaryRunnable implements Runnable1<Null<?>>, Serializable {
 1535    private final Runnable _runnable;
 1536  0 public UnaryRunnable(Runnable runnable) { _runnable = runnable; }
 1537  0 public void run(Null<?> arg) { _runnable.run(); }
 1538    }
 1539   
 1540    /** Treat a Runnable2 as a Runnable1 accepting a Pair argument. */
 1541  0 public static <T1, T2> Runnable1<Pair<T1, T2>> unary(Runnable2<? super T1, ? super T2> runnable) {
 1542  0 return new UnaryRunnable2<T1, T2>(runnable);
 1543    }
 1544   
 1545    private static final class UnaryRunnable2<T1, T2> implements Runnable1<Pair<T1, T2>>, Serializable {
 1546    private final Runnable2<? super T1, ? super T2> _runnable;
 1547  0 public UnaryRunnable2(Runnable2<? super T1, ? super T2> runnable) { _runnable = runnable; }
 1548  0 public void run(Pair<T1, T2> arg) { _runnable.run(arg.first(), arg.second()); }
 1549    }
 1550   
 1551    /** Treat a Runnable3 as a Runnable1 accepting a Triple argument. */
 1552  0 public static <T1, T2, T3> Runnable1<Triple<T1, T2, T3>>
 1553    unary(Runnable3<? super T1, ? super T2, ? super T3> runnable) {
 1554  0 return new UnaryRunnable3<T1, T2, T3>(runnable);
 1555    }
 1556   
 1557    private static final class UnaryRunnable3<T1, T2, T3>
 1558    implements Runnable1<Triple<T1, T2, T3>>, Serializable {
 1559    private final Runnable3<? super T1, ? super T2, ? super T3> _runnable;
 1560  0 public UnaryRunnable3(Runnable3<? super T1, ? super T2, ? super T3> runnable) {
 1561  0 _runnable = runnable;
 1562    }
 1563  0 public void run(Triple<T1, T2, T3> arg) {
 1564  0 _runnable.run(arg.first(), arg.second(), arg.third());
 1565    }
 1566    }
 1567   
 1568    /** Treat a Runnable4 as a Runnable1 accepting a Quad argument. */
 1569  0 public static <T1, T2, T3, T4> Runnable1<Quad<T1, T2, T3, T4>>
 1570    unary(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable) {
 1571  0 return new UnaryRunnable4<T1, T2, T3, T4>(runnable);
 1572    }
 1573   
 1574    private static final class UnaryRunnable4<T1, T2, T3, T4>
 1575    implements Runnable1<Quad<T1, T2, T3, T4>>, Serializable {
 1576    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _runnable;
 1577  0 public UnaryRunnable4(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> runnable) {
 1578  0 _runnable = runnable;
 1579    }
 1580  0 public void run(Quad<T1, T2, T3, T4> arg) {
 1581  0 _runnable.run(arg.first(), arg.second(), arg.third(), arg.fourth());
 1582    }
 1583    }
 1584   
 1585   
 1586    /**
 1587    * Treat the given thunk as a partial function, where well-defined results have a "some" return type, and
 1588    * undefined results map to "none". The provided thunk is considered to be "undefined" if
 1589    * it returns {@code null} and {@code filterNull} is {@code true}, or if it throws a {@code RuntimeException}
 1590    * that is accepted by {@code filterException}.
 1591    */
 1592  0 public static <R> Thunk<Option<R>> wrapPartial(Thunk<? extends R> thunk, boolean filterNull,
 1593    Predicate<? super RuntimeException> filterException) {
 1594  0 return new PartialThunk<R>(thunk, filterNull, filterException);
 1595    }
 1596   
 1597    private static final class PartialThunk<R> implements Thunk<Option<R>>, Serializable {
 1598    private final Thunk<? extends R> _thunk;
 1599    private final boolean _filterNull;
 1600    private final Predicate<? super RuntimeException> _filterException;
 1601  0 public PartialThunk(Thunk<? extends R> thunk, boolean filterNull,
 1602    Predicate<? super RuntimeException> filterException) {
 1603  0 _thunk = thunk; _filterNull = filterNull; _filterException = filterException;
 1604    }
 1605  0 public Option<R> value() {
 1606  0 try {
 1607  0 if (_filterNull) { return Option.<R>wrap(_thunk.value()); }
 1608  0 else { return Option.<R>some(_thunk.value()); }
 1609    }
 1610    catch (RuntimeException e) {
 1611  0 if (_filterException.contains(e)) { return Option.none(); }
 1612  0 else { throw e; }
 1613    }
 1614    }
 1615    }
 1616   
 1617    /**
 1618    * Treat the given lambda as a partial function, where well-defined results have a "some" return type, and
 1619    * undefined results map to "none". The provided lambda is considered to be "undefined" for some argument if
 1620    * it returns {@code null} and {@code filterNull} is {@code true}, or if it throws a {@code RuntimeException}
 1621    * that is accepted by {@code filterException}.
 1622    */
 1623  0 public static <T, R> Lambda<T, Option<R>> wrapPartial(Lambda<? super T, ? extends R> lambda, boolean filterNull,
 1624    Predicate<? super RuntimeException> filterException) {
 1625  0 return new PartialLambda<T, R>(lambda, filterNull, filterException);
 1626    }
 1627   
 1628    private static final class PartialLambda<T, R> implements Lambda<T, Option<R>>, Serializable {
 1629    private final Lambda<? super T, ? extends R> _lambda;
 1630    private final boolean _filterNull;
 1631    private final Predicate<? super RuntimeException> _filterException;
 1632  0 public PartialLambda(Lambda<? super T, ? extends R> lambda, boolean filterNull,
 1633    Predicate<? super RuntimeException> filterException) {
 1634  0 _lambda = lambda; _filterNull = filterNull; _filterException = filterException;
 1635    }
 1636  0 public Option<R> value(T arg) {
 1637  0 try {
 1638  0 if (_filterNull) { return Option.<R>wrap(_lambda.value(arg)); }
 1639  0 else { return Option.<R>some(_lambda.value(arg)); }
 1640    }
 1641    catch (RuntimeException e) {
 1642  0 if (_filterException.contains(e)) { return Option.none(); }
 1643  0 else { throw e; }
 1644    }
 1645    }
 1646    }
 1647   
 1648    /**
 1649    * Treat the given lambda as a partial function, where well-defined results have a "some" return type, and
 1650    * undefined results map to "none". The provided lambda is considered to be "undefined" for some set of
 1651    * arguments if it returns {@code null} and {@code filterNull} is {@code true}, or if it throws a
 1652    * {@code RuntimeException} that is accepted by {@code filterException}.
 1653    */
 1654  0 public static <T1, T2, R>
 1655    Lambda2<T1, T2, Option<R>> wrapPartial(Lambda2<? super T1, ? super T2, ? extends R> lambda, boolean filterNull,
 1656    Predicate<? super RuntimeException> filterException) {
 1657  0 return new PartialLambda2<T1, T2, R>(lambda, filterNull, filterException);
 1658    }
 1659   
 1660    private static final class PartialLambda2<T1, T2, R> implements Lambda2<T1, T2, Option<R>>, Serializable {
 1661    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 1662    private final boolean _filterNull;
 1663    private final Predicate<? super RuntimeException> _filterException;
 1664  0 public PartialLambda2(Lambda2<? super T1, ? super T2, ? extends R> lambda, boolean filterNull,
 1665    Predicate<? super RuntimeException> filterException) {
 1666  0 _lambda = lambda; _filterNull = filterNull; _filterException = filterException;
 1667    }
 1668  0 public Option<R> value(T1 arg1, T2 arg2) {
 1669  0 try {
 1670  0 if (_filterNull) { return Option.<R>wrap(_lambda.value(arg1, arg2)); }
 1671  0 else { return Option.<R>some(_lambda.value(arg1, arg2)); }
 1672    }
 1673    catch (RuntimeException e) {
 1674  0 if (_filterException.contains(e)) { return Option.none(); }
 1675  0 else { throw e; }
 1676    }
 1677    }
 1678    }
 1679   
 1680    /**
 1681    * Treat the given lambda as a partial function, where well-defined results have a "some" return type, and
 1682    * undefined results map to "none". The provided lambda is considered to be "undefined" for some set of
 1683    * arguments if it returns {@code null} and {@code filterNull} is {@code true}, or if it throws a
 1684    * {@code RuntimeException} that is accepted by {@code filterException}.
 1685    */
 1686  0 public static <T1, T2, T3, R> Lambda3<T1, T2, T3, Option<R>>
 1687    wrapPartial(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, boolean filterNull,
 1688    Predicate<? super RuntimeException> filterException) {
 1689  0 return new PartialLambda3<T1, T2, T3, R>(lambda, filterNull, filterException);
 1690    }
 1691   
 1692    private static final class PartialLambda3<T1, T2, T3, R> implements Lambda3<T1, T2, T3, Option<R>>, Serializable {
 1693    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 1694    private final boolean _filterNull;
 1695    private final Predicate<? super RuntimeException> _filterException;
 1696  0 public PartialLambda3(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda, boolean filterNull,
 1697    Predicate<? super RuntimeException> filterException) {
 1698  0 _lambda = lambda; _filterNull = filterNull; _filterException = filterException;
 1699    }
 1700  0 public Option<R> value(T1 arg1, T2 arg2, T3 arg3) {
 1701  0 try {
 1702  0 if (_filterNull) { return Option.<R>wrap(_lambda.value(arg1, arg2, arg3)); }
 1703  0 else { return Option.<R>some(_lambda.value(arg1, arg2, arg3)); }
 1704    }
 1705    catch (RuntimeException e) {
 1706  0 if (_filterException.contains(e)) { return Option.none(); }
 1707  0 else { throw e; }
 1708    }
 1709    }
 1710    }
 1711   
 1712    /**
 1713    * Treat the given lambda as a partial function, where well-defined results have a "some" return type, and
 1714    * undefined results map to "none". The provided lambda is considered to be "undefined" for some set of
 1715    * arguments if it returns {@code null} and {@code filterNull} is {@code true}, or if it throws a
 1716    * {@code RuntimeException} that is accepted by {@code filterException}.
 1717    */
 1718  0 public static <T1, T2, T3, T4, R> Lambda4<T1, T2, T3, T4, Option<R>>
 1719    wrapPartial(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda, boolean filterNull,
 1720    Predicate<? super RuntimeException> filterException) {
 1721  0 return new PartialLambda4<T1, T2, T3, T4, R>(lambda, filterNull, filterException);
 1722    }
 1723   
 1724    private static final class PartialLambda4<T1, T2, T3, T4, R>
 1725    implements Lambda4<T1, T2, T3, T4, Option<R>>, Serializable {
 1726    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 1727    private final boolean _filterNull;
 1728    private final Predicate<? super RuntimeException> _filterException;
 1729  0 public PartialLambda4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda,
 1730    boolean filterNull, Predicate<? super RuntimeException> filterException) {
 1731  0 _lambda = lambda; _filterNull = filterNull; _filterException = filterException;
 1732    }
 1733  0 public Option<R> value(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 1734  0 try {
 1735  0 if (_filterNull) { return Option.<R>wrap(_lambda.value(arg1, arg2, arg3, arg4)); }
 1736  0 else { return Option.<R>some(_lambda.value(arg1, arg2, arg3, arg4)); }
 1737    }
 1738    catch (RuntimeException e) {
 1739  0 if (_filterException.contains(e)) { return Option.none(); }
 1740  0 else { throw e; }
 1741    }
 1742    }
 1743    }
 1744   
 1745    /** A Lambda that accepts and produces {@link Option} values. Defined for conciseness. */
 1746    public interface LiftedLambda<T, R> extends Lambda<Option<? extends T>, Option<R>> {}
 1747   
 1748    /** Lift a Lambda to accept an option value, returning {@link Option#none()} in the "none" case. */
 1749  0 public static <T, R> LiftedLambda<T, R> lift(Lambda<? super T, ? extends R> lambda) {
 1750  0 return new WrappedLiftedLambda<T, R>(lambda);
 1751    }
 1752   
 1753    private static final class WrappedLiftedLambda<T, R> implements LiftedLambda<T, R>, Serializable {
 1754    private final Lambda<? super T, ? extends R> _lambda;
 1755  0 public WrappedLiftedLambda(Lambda<? super T, ? extends R> lambda) { _lambda = lambda; }
 1756  0 public Option<R> value(Option<? extends T> arg) {
 1757  0 if (arg.isSome()) { return Option.<R>some(_lambda.value(arg.unwrap())); }
 1758  0 else { return Option.none(); }
 1759    }
 1760    }
 1761   
 1762    /** A Lambda2 that accepts and produces {@link Option} values. Defined for conciseness. */
 1763    public interface LiftedLambda2<T1, T2, R>
 1764    extends Lambda2<Option<? extends T1>, Option<? extends T2>, Option<R>> {}
 1765   
 1766    /** Lift a Lambda2 to accept option values, returning {@link Option#none()} if any argument is "none". */
 1767  0 public static <T1, T2, R> LiftedLambda2<T1, T2, R> lift(Lambda2<? super T1, ? super T2, ? extends R> lambda) {
 1768  0 return new WrappedLiftedLambda2<T1, T2, R>(lambda);
 1769    }
 1770   
 1771    private static final class WrappedLiftedLambda2<T1, T2, R> implements LiftedLambda2<T1, T2, R>, Serializable {
 1772    private final Lambda2<? super T1, ? super T2, ? extends R> _lambda;
 1773  0 public WrappedLiftedLambda2(Lambda2<? super T1, ? super T2, ? extends R> lambda) { _lambda = lambda; }
 1774  0 public Option<R> value(Option<? extends T1> arg1, Option<? extends T2> arg2) {
 1775  0 if (arg1.isSome() && arg2.isSome()) { return Option.<R>some(_lambda.value(arg1.unwrap(), arg2.unwrap())); }
 1776  0 else { return Option.none(); }
 1777    }
 1778    }
 1779   
 1780    /** A Lambda3 that accepts and produces {@link Option} values. Defined for conciseness. */
 1781    public interface LiftedLambda3<T1, T2, T3, R>
 1782    extends Lambda3<Option<? extends T1>, Option<? extends T2>, Option<? extends T3>, Option<R>> {}
 1783   
 1784    /** Lift a Lambda3 to accept option values, returning {@link Option#none()} if any argument is "none". */
 1785  0 public static <T1, T2, T3, R> LiftedLambda3<T1, T2, T3, R>
 1786    lift(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) {
 1787  0 return new WrappedLiftedLambda3<T1, T2, T3, R>(lambda);
 1788    }
 1789   
 1790    private static final class WrappedLiftedLambda3<T1, T2, T3, R> implements LiftedLambda3<T1, T2, T3, R>, Serializable {
 1791    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends R> _lambda;
 1792  0 public WrappedLiftedLambda3(Lambda3<? super T1, ? super T2, ? super T3, ? extends R> lambda) { _lambda = lambda; }
 1793  0 public Option<R> value(Option<? extends T1> arg1, Option<? extends T2> arg2, Option<? extends T3> arg3) {
 1794  0 if (arg1.isSome() && arg2.isSome() && arg3.isSome()) {
 1795  0 return Option.<R>some(_lambda.value(arg1.unwrap(), arg2.unwrap(), arg3.unwrap()));
 1796    }
 1797  0 else { return Option.none(); }
 1798    }
 1799    }
 1800   
 1801    /** A Lambda4 that accepts and produces {@link Option} values. Defined for conciseness. */
 1802    public interface LiftedLambda4<T1, T2, T3, T4, R>
 1803    extends Lambda4<Option<? extends T1>, Option<? extends T2>, Option<? extends T3>, Option<? extends T4>, Option<R>> {}
 1804   
 1805    /** Lift a Lambda4 to accept option values, returning {@link Option#none()} if any argument is "none". */
 1806  0 public static <T1, T2, T3, T4, R> LiftedLambda4<T1, T2, T3, T4, R>
 1807    lift(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1808  0 return new WrappedLiftedLambda4<T1, T2, T3, T4, R>(lambda);
 1809    }
 1810   
 1811    private static final class WrappedLiftedLambda4<T1, T2, T3, T4, R>
 1812    implements LiftedLambda4<T1, T2, T3, T4, R>, Serializable {
 1813    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> _lambda;
 1814  0 public WrappedLiftedLambda4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends R> lambda) {
 1815  0 _lambda = lambda;
 1816    }
 1817  0 public Option<R> value(Option<? extends T1> arg1, Option<? extends T2> arg2, Option<? extends T3> arg3,
 1818    Option<? extends T4> arg4) {
 1819  0 if (arg1.isSome() && arg2.isSome() && arg3.isSome() && arg4.isSome()) {
 1820  0 return Option.<R>some(_lambda.value(arg1.unwrap(), arg2.unwrap(), arg3.unwrap(), arg4.unwrap()));
 1821    }
 1822  0 else { return Option.none(); }
 1823    }
 1824    }
 1825   
 1826   
 1827    /** Produce the negation ({@code !}) of {@code cond}. */
 1828  0 public static Condition negate(Condition cond) {
 1829  0 return new NegationCondition(cond);
 1830    }
 1831   
 1832    private static final class NegationCondition implements Condition, Serializable {
 1833    private final Condition _c;
 1834  0 public NegationCondition(Condition c) { _c = c; }
 1835  0 public boolean isTrue() { return !_c.isTrue(); }
 1836    }
 1837   
 1838    /** Produce the negation ({@code !}) of {@code pred}. */
 1839  3 public static <T> Predicate<T> negate(Predicate<? super T> pred) {
 1840  3 return new NegationPredicate<T>(pred);
 1841    }
 1842   
 1843    private static final class NegationPredicate<T> implements Predicate<T>, Serializable {
 1844    private final Predicate<? super T> _p;
 1845  3 public NegationPredicate(Predicate<? super T> p) { _p = p; }
 1846  0 public boolean contains(T arg) { return !_p.contains(arg); }
 1847    }
 1848   
 1849    /** Produce the negation ({@code !}) of {@code pred}. */
 1850  27 public static <T1, T2> Predicate2<T1, T2> negate(Predicate2<? super T1, ? super T2> pred) {
 1851  27 return new NegationPredicate2<T1, T2>(pred);
 1852    }
 1853   
 1854    private static final class NegationPredicate2<T1, T2> implements Predicate2<T1, T2>, Serializable {
 1855    private final Predicate2<? super T1, ? super T2> _p;
 1856  27 public NegationPredicate2(Predicate2<? super T1, ? super T2> p) { _p = p; }
 1857  0 public boolean contains(T1 arg1, T2 arg2) { return !_p.contains(arg1, arg2); }
 1858    }
 1859   
 1860    /** Produce the negation ({@code !}) of {@code pred}. */
 1861  0 public static <T1, T2, T3> Predicate3<T1, T2, T3> negate(Predicate3<? super T1, ? super T2, ? super T3> pred) {
 1862  0 return new NegationPredicate3<T1, T2, T3>(pred);
 1863    }
 1864   
 1865    private static final class NegationPredicate3<T1, T2, T3> implements Predicate3<T1, T2, T3>, Serializable {
 1866    private final Predicate3<? super T1, ? super T2, ? super T3> _p;
 1867  0 public NegationPredicate3(Predicate3<? super T1, ? super T2, ? super T3> p) { _p = p; }
 1868  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) { return !_p.contains(arg1, arg2, arg3); }
 1869    }
 1870   
 1871    /** Produce the negation ({@code !}) of {@code pred}. */
 1872  0 public static <T1, T2, T3, T4>
 1873    Predicate4<T1, T2, T3, T4> negate(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> pred) {
 1874  0 return new NegationPredicate4<T1, T2, T3, T4>(pred);
 1875    }
 1876   
 1877    private static final class NegationPredicate4<T1, T2, T3, T4> implements Predicate4<T1, T2, T3, T4>, Serializable {
 1878    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _p;
 1879  0 public NegationPredicate4(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p) { _p = p; }
 1880  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { return !_p.contains(arg1, arg2, arg3, arg4); }
 1881    }
 1882   
 1883   
 1884    /** Produce the conjunction ({@code &&}) of {@code c1} and {@code c2}. */
 1885  0 public static Condition and(Condition c1, Condition c2) {
 1886  0 return new AndCondition(IterUtil.make(c1, c2));
 1887    }
 1888   
 1889    /** Produce the conjunction ({@code &&}) of {@code c1}, {@code c2}, and {@code c3}. */
 1890  0 public static Condition and(Condition c1, Condition c2, Condition c3) {
 1891  0 return new AndCondition(IterUtil.make(c1, c2, c3));
 1892    }
 1893   
 1894    /** Produce the conjunction ({@code &&}) of the given conditions. */
 1895  0 public static Condition and0(Iterable<? extends Condition> conds) {
 1896  0 return new AndCondition(conds);
 1897    }
 1898   
 1899    private static final class AndCondition implements Condition, Serializable {
 1900    private final Iterable<? extends Condition> _conds;
 1901  0 public AndCondition(Iterable<? extends Condition> conds) { _conds = conds; }
 1902  0 public boolean isTrue() {
 1903  0 for (Condition c : _conds) { if (!c.isTrue()) { return false; } }
 1904  0 return true;
 1905    }
 1906    }
 1907   
 1908    /** Produce the conjunction ({@code &&}) of {@code p1} and {@code p2}. */
 1909  3 public static <T> Predicate<T> and(Predicate<? super T> p1, Predicate<? super T> p2) {
 1910    // explicit type argument required due to compiler (or language) bug
 1911  3 return new AndPredicate<T>(IterUtil.<Predicate<? super T>>make(p1, p2));
 1912    }
 1913   
 1914    /** Produce the conjunction ({@code &&}) of {@code p1}, {@code p2}, and {@code p3}. */
 1915  0 public static <T> Predicate<T> and(Predicate<? super T> p1, Predicate<? super T> p2, Predicate<? super T> p3) {
 1916  0 return new AndPredicate<T>(IterUtil.<Predicate<? super T>>make(p1, p2, p3));
 1917    }
 1918   
 1919    /** Produce the conjunction ({@code &&}) of the given predicates. */
 1920  0 public static <T> Predicate<T> and(Iterable<? extends Predicate<? super T>> preds) {
 1921  0 return new AndPredicate<T>(preds);
 1922    }
 1923   
 1924    private static final class AndPredicate<T> implements Predicate<T>, Serializable {
 1925    private final Iterable<? extends Predicate<? super T>> _preds;
 1926  3 public AndPredicate(Iterable<? extends Predicate<? super T>> preds) { _preds = preds; }
 1927  3 public boolean contains(T arg) {
 1928  2 for (Predicate<? super T> p : _preds) { if (!p.contains(arg)) { return false; } }
 1929  1 return true;
 1930    }
 1931    }
 1932   
 1933    /** Produce the conjunction ({@code &&}) of {@code p1} and {@code p2}. */
 1934  0 public static <T1, T2> Predicate2<T1, T2> and(Predicate2<? super T1, ? super T2> p1,
 1935    Predicate2<? super T1, ? super T2> p2) {
 1936  0 return new AndPredicate2<T1, T2>(IterUtil.<Predicate2<? super T1, ? super T2>>make(p1, p2));
 1937    }
 1938   
 1939    /** Produce the conjunction ({@code &&}) of {@code p1}, {@code p2}, and {@code p3}. */
 1940  0 public static <T1, T2> Predicate2<T1, T2> and(Predicate2<? super T1, ? super T2> p1,
 1941    Predicate2<? super T1, ? super T2> p2,
 1942    Predicate2<? super T1, ? super T2> p3) {
 1943  0 return new AndPredicate2<T1, T2>(IterUtil.<Predicate2<? super T1, ? super T2>>make(p1, p2, p3));
 1944    }
 1945   
 1946    /**
 1947    * Produce the conjunction ({@code &&}) of the given predicates. The name {@code and2} is used to avoid a name
 1948    * clash with {@link #and(Iterable)} (due to erasure).
 1949    */
 1950  0 public static <T1, T2>
 1951    Predicate2<T1, T2> and2(final Iterable<? extends Predicate2<? super T1, ? super T2>> preds) {
 1952  0 return new AndPredicate2<T1, T2>(preds);
 1953    }
 1954   
 1955    private static final class AndPredicate2<T1, T2> implements Predicate2<T1, T2>, Serializable {
 1956    private final Iterable<? extends Predicate2<? super T1, ? super T2>> _preds;
 1957  0 public AndPredicate2(Iterable<? extends Predicate2<? super T1, ? super T2>> preds) { _preds = preds; }
 1958  0 public boolean contains(T1 arg1, T2 arg2) {
 1959  0 for (Predicate2<? super T1, ? super T2> p : _preds) { if (!p.contains(arg1, arg2)) { return false; } }
 1960  0 return true;
 1961    }
 1962    }
 1963   
 1964    /** Produce the conjunction ({@code &&}) of {@code p1} and {@code p2}. */
 1965  0 public static <T1, T2, T3>
 1966    Predicate3<T1, T2, T3> and(Predicate3<? super T1, ? super T2, ? super T3> p1,
 1967    Predicate3<? super T1, ? super T2, ? super T3> p2) {
 1968  0 return new AndPredicate3<T1, T2, T3>(IterUtil.<Predicate3<? super T1, ? super T2, ? super T3>>
 1969    make(p1, p2));
 1970    }
 1971   
 1972    /** Produce the conjunction ({@code &&}) of {@code p1}, {@code p2}, and {@code p3}. */
 1973  0 public static <T1, T2, T3>
 1974    Predicate3<T1, T2, T3> and(Predicate3<? super T1, ? super T2, ? super T3> p1,
 1975    Predicate3<? super T1, ? super T2, ? super T3> p2,
 1976    Predicate3<? super T1, ? super T2, ? super T3> p3) {
 1977  0 return new AndPredicate3<T1, T2, T3>(IterUtil.<Predicate3<? super T1, ? super T2, ? super T3>>
 1978    make(p1, p2, p3));
 1979    }
 1980   
 1981    /**
 1982    * Produce the conjunction ({@code &&}) of the given predicates. The name {@code and3} is used to avoid a name
 1983    * clash with {@link #and(Iterable)} (due to erasure).
 1984    */
 1985  0 public static <T1, T2, T3>
 1986    Predicate3<T1, T2, T3> and3(Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> preds) {
 1987  0 return new AndPredicate3<T1, T2, T3>(preds);
 1988    }
 1989   
 1990    private static final class AndPredicate3<T1, T2, T3> implements Predicate3<T1, T2, T3>, Serializable {
 1991    private final Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> _preds;
 1992  0 public AndPredicate3(Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> preds) {
 1993  0 _preds = preds;
 1994    }
 1995  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) {
 1996  0 for (Predicate3<? super T1, ? super T2, ? super T3> p : _preds) {
 1997  0 if (!p.contains(arg1, arg2, arg3)) { return false; }
 1998    }
 1999  0 return true;
 2000    }
 2001    }
 2002   
 2003    /** Produce the conjunction ({@code &&}) of {@code p1} and {@code p2}. */
 2004  0 public static <T1, T2, T3, T4>
 2005    Predicate4<T1, T2, T3, T4> and(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p1,
 2006    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p2) {
 2007  0 return new AndPredicate4<T1, T2, T3, T4>(IterUtil.<Predicate4<? super T1, ? super T2, ? super T3, ? super T4>>
 2008    make(p1, p2));
 2009    }
 2010   
 2011    /** Produce the conjunction ({@code &&}) of {@code p1}, {@code p2}, and {@code p3}. */
 2012  0 public static <T1, T2, T3, T4>
 2013    Predicate4<T1, T2, T3, T4> and(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p1,
 2014    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p2,
 2015    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p3) {
 2016  0 return new AndPredicate4<T1, T2, T3, T4>(IterUtil.<Predicate4<? super T1, ? super T2, ? super T3, ? super T4>>
 2017    make(p1, p2, p3));
 2018    }
 2019   
 2020    /**
 2021    * Produce the conjunction ({@code &&}) of the given predicates. The name {@code and4} is used to avoid a name
 2022    * clash with {@link #and(Iterable)} (due to erasure).
 2023    */
 2024  0 public static <T1, T2, T3, T4> Predicate4<T1, T2, T3, T4>
 2025    and4(Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> preds) {
 2026  0 return new AndPredicate4<T1, T2, T3, T4>(preds);
 2027    }
 2028   
 2029    private static final class AndPredicate4<T1, T2, T3, T4> implements Predicate4<T1, T2, T3, T4>, Serializable {
 2030    private final Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> _preds;
 2031  0 public AndPredicate4(Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> preds) {
 2032  0 _preds = preds;
 2033    }
 2034  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 2035  0 for (Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p : _preds) {
 2036  0 if (!p.contains(arg1, arg2, arg3, arg4)) { return false; }
 2037    }
 2038  0 return true;
 2039    }
 2040    }
 2041   
 2042   
 2043    /** Produce the disjunction ({@code ||}) of {@code c1} and {@code c2}. */
 2044  0 public static Condition or(Condition c1, Condition c2) {
 2045  0 return new OrCondition(IterUtil.make(c1, c2));
 2046    }
 2047   
 2048    /** Produce the disjunction ({@code ||}) of {@code c1}, {@code c2}, and {@code c3}. */
 2049  0 public static Condition or(Condition c1, Condition c2, Condition c3) {
 2050  0 return new OrCondition(IterUtil.make(c1, c2, c3));
 2051    }
 2052   
 2053    /** Produce the disjunction ({@code ||}) of the given conditions. */
 2054  0 public static Condition or0(Iterable<? extends Condition> conds) {
 2055  0 return new OrCondition(conds);
 2056    }
 2057   
 2058    private static final class OrCondition implements Condition, Serializable {
 2059    private final Iterable<? extends Condition> _conds;
 2060  0 public OrCondition(Iterable<? extends Condition> conds) { _conds = conds; }
 2061  0 public boolean isTrue() {
 2062  0 for (Condition c : _conds) { if (c.isTrue()) { return true; } }
 2063  0 return false;
 2064    }
 2065    }
 2066   
 2067    /** Produce the disjunction ({@code ||}) of {@code p1} and {@code p2}. */
 2068  0 public static <T> Predicate<T> or(Predicate<? super T> p1, Predicate<? super T> p2) {
 2069    // explicit type argument required due to compiler (or language) bug
 2070  0 return new OrPredicate<T>(IterUtil.<Predicate<? super T>>make(p1, p2));
 2071    }
 2072   
 2073    /** Produce the disjunction ({@code ||}) of {@code p1}, {@code p2}, and {@code p3}. */
 2074  3 public static <T> Predicate<T> or(Predicate<? super T> p1, Predicate<? super T> p2, Predicate<? super T> p3) {
 2075  3 return new OrPredicate<T>(IterUtil.<Predicate<? super T>>make(p1, p2, p3));
 2076    }
 2077   
 2078    /** Produce the disjunction ({@code ||}) of the given predicates. */
 2079  0 public static <T> Predicate<T> or(Iterable<? extends Predicate<? super T>> preds) {
 2080  0 return new OrPredicate<T>(preds);
 2081    }
 2082   
 2083    private static final class OrPredicate<T> implements Predicate<T>, Serializable {
 2084    private final Iterable<? extends Predicate<? super T>> _preds;
 2085  3 public OrPredicate(Iterable<? extends Predicate<? super T>> preds) { _preds = preds; }
 2086  3 public boolean contains(T arg) {
 2087  2 for (Predicate<? super T> p : _preds) { if (p.contains(arg)) { return true; } }
 2088  1 return false;
 2089    }
 2090    }
 2091   
 2092    /** Produce the disjunction ({@code ||}) of {@code p1} and {@code p2}. */
 2093  0 public static <T1, T2> Predicate2<T1, T2> or(Predicate2<? super T1, ? super T2> p1,
 2094    Predicate2<? super T1, ? super T2> p2) {
 2095  0 return new OrPredicate2<T1, T2>(IterUtil.<Predicate2<? super T1, ? super T2>>make(p1, p2));
 2096    }
 2097   
 2098    /** Produce the disjunction ({@code ||}) of {@code p1}, {@code p2}, and {@code p3}. */
 2099  0 public static <T1, T2> Predicate2<T1, T2> or(Predicate2<? super T1, ? super T2> p1,
 2100    Predicate2<? super T1, ? super T2> p2,
 2101    Predicate2<? super T1, ? super T2> p3) {
 2102  0 return new OrPredicate2<T1, T2>(IterUtil.<Predicate2<? super T1, ? super T2>>make(p1, p2, p3));
 2103    }
 2104   
 2105    /**
 2106    * Produce the conjunction ({@code ||}) of the given predicates. The name {@code or2} is used to avoid a name
 2107    * clash with {@link #or(Iterable)} (due to erasure).
 2108    */
 2109  0 public static <T1, T2> Predicate2<T1, T2> or2(Iterable<? extends Predicate2<? super T1, ? super T2>> preds) {
 2110  0 return new OrPredicate2<T1, T2>(preds);
 2111    }
 2112   
 2113    private static final class OrPredicate2<T1, T2> implements Predicate2<T1, T2>, Serializable {
 2114    private final Iterable<? extends Predicate2<? super T1, ? super T2>> _preds;
 2115  0 public OrPredicate2(Iterable<? extends Predicate2<? super T1, ? super T2>> preds) { _preds = preds; }
 2116  0 public boolean contains(T1 arg1, T2 arg2) {
 2117  0 for (Predicate2<? super T1, ? super T2> p : _preds) { if (p.contains(arg1, arg2)) { return true; } }
 2118  0 return false;
 2119    }
 2120    }
 2121   
 2122    /** Produce the disjunction ({@code ||}) of {@code p1} and {@code p2}. */
 2123  0 public static <T1, T2, T3> Predicate3<T1, T2, T3> or(Predicate3<? super T1, ? super T2, ? super T3> p1,
 2124    Predicate3<? super T1, ? super T2, ? super T3> p2) {
 2125  0 return new OrPredicate3<T1, T2, T3>(IterUtil.<Predicate3<? super T1, ? super T2, ? super T3>>
 2126    make(p1, p2));
 2127    }
 2128   
 2129    /** Produce the disjunction ({@code ||}) of {@code p1}, {@code p2}, and {@code p3}. */
 2130  0 public static <T1, T2, T3> Predicate3<T1, T2, T3> or(Predicate3<? super T1, ? super T2, ? super T3> p1,
 2131    Predicate3<? super T1, ? super T2, ? super T3> p2,
 2132    Predicate3<? super T1, ? super T2, ? super T3> p3) {
 2133  0 return new OrPredicate3<T1, T2, T3>(IterUtil.<Predicate3<? super T1, ? super T2, ? super T3>>
 2134    make(p1, p2, p3));
 2135    }
 2136   
 2137    /**
 2138    * Produce the conjunction ({@code ||}) of the given predicates. The name {@code or3} is used to avoid a name
 2139    * clash with {@link #or(Iterable)} (due to erasure).
 2140    */
 2141  0 public static <T1, T2, T3>
 2142    Predicate3<T1, T2, T3> or3(Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> preds) {
 2143  0 return new OrPredicate3<T1, T2, T3>(preds);
 2144    }
 2145   
 2146    private static final class OrPredicate3<T1, T2, T3> implements Predicate3<T1, T2, T3>, Serializable {
 2147    private final Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> _preds;
 2148  0 public OrPredicate3(Iterable<? extends Predicate3<? super T1, ? super T2, ? super T3>> preds) {
 2149  0 _preds = preds;
 2150    }
 2151  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) {
 2152  0 for (Predicate3<? super T1, ? super T2, ? super T3> p : _preds) {
 2153  0 if (p.contains(arg1, arg2, arg3)) { return true; }
 2154    }
 2155  0 return false;
 2156    }
 2157    }
 2158   
 2159    /** Produce the disjunction ({@code ||}) of {@code p1} and {@code p2}. */
 2160  0 public static <T1, T2, T3, T4>
 2161    Predicate4<T1, T2, T3, T4> or(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p1,
 2162    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p2) {
 2163  0 return new OrPredicate4<T1, T2, T3, T4>(IterUtil.<Predicate4<? super T1, ? super T2, ? super T3, ? super T4>>
 2164    make(p1, p2));
 2165    }
 2166   
 2167    /** Produce the disjunction ({@code ||}) of {@code p1}, {@code p2}, and {@code p3}. */
 2168  0 public static <T1, T2, T3, T4>
 2169    Predicate4<T1, T2, T3, T4> or(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p1,
 2170    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p2,
 2171    Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p3) {
 2172  0 return new OrPredicate4<T1, T2, T3, T4>(IterUtil.<Predicate4<? super T1, ? super T2, ? super T3, ? super T4>>
 2173    make(p1, p2, p3));
 2174    }
 2175   
 2176    /**
 2177    * Produce the conjunction ({@code ||}) of the given predicates. The name {@code or4} is used to avoid a name
 2178    * clash with {@link #or(Iterable)} (due to erasure).
 2179    */
 2180  0 public static <T1, T2, T3, T4> Predicate4<T1, T2, T3, T4>
 2181    or4(Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> preds) {
 2182  0 return new OrPredicate4<T1, T2, T3, T4>(preds);
 2183    }
 2184   
 2185    private static final class OrPredicate4<T1, T2, T3, T4> implements Predicate4<T1, T2, T3, T4>, Serializable {
 2186    private final Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> _preds;
 2187  0 public OrPredicate4(Iterable<? extends Predicate4<? super T1, ? super T2, ? super T3, ? super T4>> preds) {
 2188  0 _preds = preds;
 2189    }
 2190  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
 2191  0 for (Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p : _preds) {
 2192  0 if (p.contains(arg1, arg2, arg3, arg4)) { return true; }
 2193    }
 2194  0 return false;
 2195    }
 2196    }
 2197   
 2198    /** Create a runnable that executes the given thunk (ignoring the result). */
 2199  0 public static Runnable asRunnable(Thunk<?> thunk) { return new ThunkRunnable(thunk); }
 2200   
 2201    private static final class ThunkRunnable implements Runnable, Serializable {
 2202    private final Thunk<?> _t;
 2203  0 public ThunkRunnable(Thunk<?> t) { _t = t; }
 2204  0 public void run() { _t.value(); }
 2205    }
 2206   
 2207    /** Create a runnable that executes the given lambda (ignoring the result). */
 2208  0 public static <T> Runnable1<T> asRunnable(Lambda<? super T, ?> lambda) {
 2209  0 return new LambdaRunnable1<T>(lambda);
 2210    }
 2211   
 2212    private static final class LambdaRunnable1<T> implements Runnable1<T>, Serializable {
 2213    private final Lambda<? super T, ?> _l;
 2214  0 public LambdaRunnable1(Lambda<? super T, ?> l) { _l = l; }
 2215  0 public void run(T arg) { _l.value(arg); }
 2216    }
 2217   
 2218    /** Create a runnable that executes the given lambda (ignoring the result). */
 2219  0 public static <T1, T2> Runnable2<T1, T2> asRunnable(Lambda2<? super T1, ? super T2, ?> lambda) {
 2220  0 return new LambdaRunnable2<T1, T2>(lambda);
 2221    }
 2222   
 2223    private static final class LambdaRunnable2<T1, T2> implements Runnable2<T1, T2>, Serializable {
 2224    private final Lambda2<? super T1, ? super T2, ?> _l;
 2225  0 public LambdaRunnable2(Lambda2<? super T1, ? super T2, ?> l) { _l = l; }
 2226  0 public void run(T1 arg1, T2 arg2) { _l.value(arg1, arg2); }
 2227    }
 2228   
 2229    /** Create a runnable that executes the given lambda (ignoring the result). */
 2230  0 public static <T1, T2, T3>
 2231    Runnable3<T1, T2, T3> asRunnable(Lambda3<? super T1, ? super T2, ? super T3, ?> lambda) {
 2232  0 return new LambdaRunnable3<T1, T2, T3>(lambda);
 2233    }
 2234   
 2235    private static final class LambdaRunnable3<T1, T2, T3> implements Runnable3<T1, T2, T3>, Serializable {
 2236    private final Lambda3<? super T1, ? super T2, ? super T3, ?> _l;
 2237  0 public LambdaRunnable3(Lambda3<? super T1, ? super T2, ? super T3, ?> l) { _l = l; }
 2238  0 public void run(T1 arg1, T2 arg2, T3 arg3) { _l.value(arg1, arg2, arg3); }
 2239    }
 2240   
 2241    /** Create a runnable that executes the given lambda (ignoring the result). */
 2242  0 public static <T1, T2, T3, T4>
 2243    Runnable4<T1, T2, T3, T4> asRunnable(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ?> lambda) {
 2244  0 return new LambdaRunnable4<T1, T2, T3, T4>(lambda);
 2245    }
 2246   
 2247    private static final class LambdaRunnable4<T1, T2, T3, T4> implements Runnable4<T1, T2, T3, T4>, Serializable {
 2248    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ?> _l;
 2249  0 public LambdaRunnable4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ?> l) { _l = l; }
 2250  0 public void run(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { _l.value(arg1, arg2, arg3, arg4); }
 2251    }
 2252   
 2253    /** Create a thunk that executes the given runnable, then returns {@code null}. */
 2254  1 public static Thunk<Void> asThunk(Runnable r) { return new RunnableThunk<Void>(r, null); }
 2255   
 2256    /** Create a thunk that executes the given runnable, then returns {@code result}. */
 2257  0 public static <R> Thunk<R> asThunk(Runnable r, R result) { return new RunnableThunk<R>(r, result); }
 2258   
 2259    private static final class RunnableThunk<R> implements Thunk<R>, Serializable {
 2260    private final Runnable _r;
 2261    private final R _result;
 2262  1 public RunnableThunk(Runnable r, R result) { _r = r; _result = result; }
 2263  1 public R value() { _r.run(); return _result; }
 2264    }
 2265   
 2266    /** Create a lambda that executes the given runnable, then returns {@code null}. */
 2267  0 public static <T> Lambda<T, Void> asLambda(Runnable1<? super T> r) {
 2268  0 return new RunnableLambda<T, Void>(r, null);
 2269    }
 2270   
 2271    /** Create a lambda that executes the given runnable, then returns {@code result}. */
 2272  0 public static <T, R> Lambda<T, R> asLambda(Runnable1<? super T> r, R result) {
 2273  0 return new RunnableLambda<T, R>(r, result);
 2274    }
 2275   
 2276    private static final class RunnableLambda<T, R> implements Lambda<T, R>, Serializable {
 2277    private final Runnable1<? super T> _r;
 2278    private final R _result;
 2279  0 public RunnableLambda(Runnable1<? super T> r, R result) { _r = r; _result = result; }
 2280  0 public R value(T arg) { _r.run(arg); return _result; }
 2281    }
 2282   
 2283    /** Create a lambda that executes the given runnable, then returns {@code null}. */
 2284  0 public static <T1, T2> Lambda2<T1, T2, Void> asLambda(Runnable2<? super T1, ? super T2> r) {
 2285  0 return new RunnableLambda2<T1, T2, Void>(r, null);
 2286    }
 2287   
 2288    /** Create a lambda that executes the given runnable, then returns {@code result}. */
 2289  0 public static <T1, T2, R> Lambda2<T1, T2, R> asLambda(Runnable2<? super T1, ? super T2> r, R result) {
 2290  0 return new RunnableLambda2<T1, T2, R>(r, result);
 2291    }
 2292   
 2293    private static final class RunnableLambda2<T1, T2, R> implements Lambda2<T1, T2, R>, Serializable {
 2294    private final Runnable2<? super T1, ? super T2> _r;
 2295    private final R _result;
 2296  0 public RunnableLambda2(Runnable2<? super T1, ? super T2> r, R result) { _r = r; _result = result; }
 2297  0 public R value(T1 arg1, T2 arg2) { _r.run(arg1, arg2); return _result; }
 2298    }
 2299   
 2300    /** Create a lambda that executes the given runnable, then returns {@code null}. */
 2301  0 public static <T1, T2, T3>
 2302    Lambda3<T1, T2, T3, Void> asLambda(Runnable3<? super T1, ? super T2, ? super T3> r) {
 2303  0 return new RunnableLambda3<T1, T2, T3, Void>(r, null);
 2304    }
 2305   
 2306    /** Create a lambda that executes the given runnable, then returns {@code result}. */
 2307  0 public static <T1, T2, T3, R>
 2308    Lambda3<T1, T2, T3, R> asLambda(Runnable3<? super T1, ? super T2, ? super T3> r, R result) {
 2309  0 return new RunnableLambda3<T1, T2, T3, R>(r, result);
 2310    }
 2311   
 2312    private static final class RunnableLambda3<T1, T2, T3, R> implements Lambda3<T1, T2, T3, R>, Serializable {
 2313    private final Runnable3<? super T1, ? super T2, ? super T3> _r;
 2314    private final R _result;
 2315  0 public RunnableLambda3(Runnable3<? super T1, ? super T2, ? super T3> r, R result) { _r = r; _result = result; }
 2316  0 public R value(T1 arg1, T2 arg2, T3 arg3) { _r.run(arg1, arg2, arg3); return _result; }
 2317    }
 2318   
 2319    /** Create a lambda that executes the given runnable, then returns {@code null}. */
 2320  0 public static <T1, T2, T3, T4> Lambda4<T1, T2, T3, T4, Void>
 2321    asLambda(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r) {
 2322  0 return new RunnableLambda4<T1, T2, T3, T4, Void>(r, null);
 2323    }
 2324   
 2325    /** Create a lambda that executes the given runnable, then returns {@code result}. */
 2326  0 public static <T1, T2, T3, T4, R> Lambda4<T1, T2, T3, T4, R>
 2327    asLambda(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r, R result) {
 2328  0 return new RunnableLambda4<T1, T2, T3, T4, R>(r, result);
 2329    }
 2330   
 2331    private static final class RunnableLambda4<T1, T2, T3, T4, R>
 2332    implements Lambda4<T1, T2, T3, T4, R>, Serializable {
 2333    private final Runnable4<? super T1, ? super T2, ? super T3, ? super T4> _r;
 2334    private final R _result;
 2335  0 public RunnableLambda4(Runnable4<? super T1, ? super T2, ? super T3, ? super T4> r, R result) {
 2336  0 _r = r;
 2337  0 _result = result;
 2338    }
 2339  0 public R value(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { _r.run(arg1, arg2, arg3, arg4); return _result; }
 2340    }
 2341   
 2342    /** Create a condition based on an input that acts as a condition but is not typed as one. */
 2343  0 public static Condition asCondition(Thunk<? extends Boolean> thunk) {
 2344  0 return new ThunkCondition(thunk);
 2345    }
 2346   
 2347    private static final class ThunkCondition implements Condition, Serializable {
 2348    private final Thunk<? extends Boolean> _thunk;
 2349  0 public ThunkCondition(Thunk<? extends Boolean> thunk) { _thunk = thunk; }
 2350  0 public boolean isTrue() { return _thunk.value(); }
 2351    }
 2352   
 2353    /** Create a predicate based on an input that acts as a predicate but is not typed as one. */
 2354  0 public static <T> Predicate<T> asPredicate(Lambda<? super T, ? extends Boolean> lambda) {
 2355  0 return new LambdaPredicate<T>(lambda);
 2356    }
 2357   
 2358    private static final class LambdaPredicate<T> implements Predicate<T>, Serializable {
 2359    private final Lambda<? super T, ? extends Boolean> _l;
 2360  0 public LambdaPredicate(Lambda<? super T, ? extends Boolean> l) { _l = l; }
 2361  0 public boolean contains(T arg) { return _l.value(arg); }
 2362    }
 2363   
 2364    /** Create a predicate based on an input that acts as a predicate but is not typed as one. */
 2365  0 public static <T1, T2> Predicate2<T1, T2> asPredicate(Lambda2<? super T1, ? super T2, ? extends Boolean> lambda) {
 2366  0 return new LambdaPredicate2<T1, T2>(lambda);
 2367    }
 2368   
 2369    private static final class LambdaPredicate2<T1, T2> implements Predicate2<T1, T2>, Serializable {
 2370    private final Lambda2<? super T1, ? super T2, ? extends Boolean> _l;
 2371  0 public LambdaPredicate2(Lambda2<? super T1, ? super T2, ? extends Boolean> l) { _l = l; }
 2372  0 public boolean contains(T1 arg1, T2 arg2) { return _l.value(arg1, arg2); }
 2373    }
 2374   
 2375    /** Create a predicate based on an input that acts as a predicate but is not typed as one. */
 2376  0 public static <T1, T2, T3>
 2377    Predicate3<T1, T2, T3> asPredicate(Lambda3<? super T1, ? super T2, ? super T3, ? extends Boolean> lambda) {
 2378  0 return new LambdaPredicate3<T1, T2, T3>(lambda);
 2379    }
 2380   
 2381    private static final class LambdaPredicate3<T1, T2, T3> implements Predicate3<T1, T2, T3>, Serializable {
 2382    private final Lambda3<? super T1, ? super T2, ? super T3, ? extends Boolean> _l;
 2383  0 public LambdaPredicate3(Lambda3<? super T1, ? super T2, ? super T3, ? extends Boolean> l) { _l = l; }
 2384  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3) { return _l.value(arg1, arg2, arg3); }
 2385    }
 2386   
 2387    /** Create a predicate based on an input that acts as a predicate but is not typed as one. */
 2388  0 public static <T1, T2, T3, T4> Predicate4<T1, T2, T3, T4>
 2389    asPredicate(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends Boolean> lambda) {
 2390  0 return new LambdaPredicate4<T1, T2, T3, T4>(lambda);
 2391    }
 2392   
 2393    private static final class LambdaPredicate4<T1, T2, T3, T4> implements Predicate4<T1, T2, T3, T4>, Serializable {
 2394    private final Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends Boolean> _l;
 2395  0 public LambdaPredicate4(Lambda4<? super T1, ? super T2, ? super T3, ? super T4, ? extends Boolean> l) { _l = l; }
 2396  0 public boolean contains(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { return _l.value(arg1, arg2, arg3, arg4); }
 2397    }
 2398   
 2399   
 2400    /** Create a Boolean thunk based on a condition. */
 2401  0 public static Thunk<Boolean> asThunk(Condition cond) {
 2402  0 return new ConditionThunk(cond);
 2403    }
 2404   
 2405    private static final class ConditionThunk implements Thunk<Boolean>, Serializable {
 2406    private final Condition _c;
 2407  0 public ConditionThunk(Condition c) { _c = c; }
 2408  0 public Boolean value() { return _c.isTrue(); }
 2409    }
 2410   
 2411    /** Create a Boolean lambda based on a predicate. */
 2412  0 public static <T> Lambda<T, Boolean> asLambda(Predicate<? super T> predicate) {
 2413  0 return new PredicateLambda<T>(predicate);
 2414    }
 2415   
 2416    private static final class PredicateLambda<T> implements Lambda<T, Boolean>, Serializable {
 2417    private final Predicate<? super T> _p;
 2418  0 public PredicateLambda(Predicate<? super T> p) { _p = p; }
 2419  0 public Boolean value(T arg) { return _p.contains(arg); }
 2420    }
 2421   
 2422    /** Create a Boolean lambda based on a predicate. */
 2423  394 public static <T1, T2> Lambda2<T1, T2, Boolean> asLambda(Predicate2<? super T1, ? super T2> predicate) {
 2424  394 return new PredicateLambda2<T1, T2>(predicate);
 2425    }
 2426   
 2427    private static final class PredicateLambda2<T1, T2> implements Lambda2<T1, T2, Boolean>, Serializable {
 2428    private final Predicate2<? super T1, ? super T2> _p;
 2429  394 public PredicateLambda2(Predicate2<? super T1, ? super T2> p) { _p = p; }
 2430  0 public Boolean value(T1 arg1, T2 arg2) { return _p.contains(arg1, arg2); }
 2431    }
 2432   
 2433    /** Create a Boolean lambda based on a predicate. */
 2434  0 public static <T1, T2, T3>
 2435    Lambda3<T1, T2, T3, Boolean> asLambda(Predicate3<? super T1, ? super T2, ? super T3> predicate) {
 2436  0 return new PredicateLambda3<T1, T2, T3>(predicate);
 2437    }
 2438   
 2439    private static final class PredicateLambda3<T1, T2, T3> implements Lambda3<T1, T2, T3, Boolean>, Serializable {
 2440    private final Predicate3<? super T1, ? super T2, ? super T3> _p;
 2441  0 public PredicateLambda3(Predicate3<? super T1, ? super T2, ? super T3> p) { _p = p; }
 2442  0 public Boolean value(T1 arg1, T2 arg2, T3 arg3) { return _p.contains(arg1, arg2, arg3); }
 2443    }
 2444   
 2445    /** Create a Boolean lambda based on a predicate. */
 2446  0 public static <T1, T2, T3, T4> Lambda4<T1, T2, T3, T4, Boolean>
 2447    asLambda(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> predicate) {
 2448  0 return new PredicateLambda4<T1, T2, T3, T4>(predicate);
 2449    }
 2450   
 2451    private static final class PredicateLambda4<T1, T2, T3, T4> implements Lambda4<T1, T2, T3, T4, Boolean>, Serializable {
 2452    private final Predicate4<? super T1, ? super T2, ? super T3, ? super T4> _p;
 2453  0 public PredicateLambda4(Predicate4<? super T1, ? super T2, ? super T3, ? super T4> p) { _p = p; }
 2454  0 public Boolean value(T1 arg1, T2 arg2, T3 arg3, T4 arg4) { return _p.contains(arg1, arg2, arg3, arg4); }
 2455    }
 2456   
 2457    }