1 33 package net.sf.jga.fn.logical; 34 35 import net.sf.jga.fn.BinaryPredicate; 36 import net.sf.jga.fn.BinaryFunctor; 37 38 47 48 public class BinaryNegate<T1, T2> extends BinaryPredicate<T1, T2> { 49 50 static final long serialVersionUID = 3005632919263334394L; 51 52 private BinaryFunctor<? super T1, ? super T2, Boolean > _p; 53 54 58 public BinaryNegate(BinaryFunctor<? super T1, ? super T2, Boolean > p) { 59 if (p == null) { 60 throw new IllegalArgumentException ("Child Predicate may not be null"); 61 } 62 63 _p = p; 64 } 65 66 70 public BinaryFunctor<? super T1, ? super T2, Boolean > getPredicate() { 71 return _p; 72 } 73 74 76 82 public Boolean fn(T1 x, T2 y) { 83 return ! _p.fn(x,y); 84 } 85 86 90 public void accept(net.sf.jga.fn.Visitor v) { 91 if (v instanceof BinaryNegate.Visitor) 92 ((BinaryNegate.Visitor)v).visit(this); 93 else 94 v.visit(this); 95 } 96 97 99 public String toString() { 100 return "BinaryNegate("+_p+")"; 101 } 102 103 105 109 public interface Visitor extends net.sf.jga.fn.Visitor { 110 public void visit(BinaryNegate host); 111 } 112 } 113 | Popular Tags |