1 package uk.co.jezuk.mango; 2 3 8 public class Bind 9 { 10 17 static public UnaryFunction First(final BinaryFunction f, final Object c) 18 { 19 return new UnaryFunction() { 20 private BinaryFunction fn_; 21 private Object c_; 22 { fn_ = f; c_ = c; } 23 public Object fn(Object arg) { return fn_.fn(c_, arg); } 24 }; 25 } 27 32 static public Predicate First(final BinaryPredicate p, final Object c) 33 { 34 return new Predicate() { 35 private BinaryPredicate test_; 36 private Object c_; 37 { test_ = p; c_ = c; } 38 public boolean test(Object arg) { return test_.test(c_, arg); } 39 }; 40 } 42 49 static public UnaryFunction Second(final BinaryFunction f, final Object c) 50 { 51 return new UnaryFunction() { 52 private BinaryFunction fn_; 53 private Object c_; 54 { fn_ = f; c_ = c; } 55 public Object fn(Object arg) { return fn_.fn(arg, c_); } 56 }; 57 } 59 64 static public Predicate Second(final BinaryPredicate p, final Object c) 65 { 66 return new Predicate() { 67 private BinaryPredicate test_; 68 private Object c_; 69 { test_ = p; c_ = c; } 70 public boolean test(Object arg) { return test_.test(arg, c_); } 71 }; 72 } 74 private Bind() { } 76 } 78 | Popular Tags |