1 33 package net.sf.jga.fn.logical; 34 35 import net.sf.jga.fn.UnaryPredicate; 36 import net.sf.jga.fn.UnaryFunctor; 37 38 47 48 public class UnaryNegate<T> extends UnaryPredicate<T> { 49 50 static final long serialVersionUID = -722445812960547108L; 51 52 private UnaryFunctor<? super T, Boolean > _p; 53 54 58 public UnaryNegate(UnaryFunctor<? super T, 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 UnaryFunctor<? super T,Boolean > getPredicate() { return _p; } 71 72 74 80 public Boolean fn(T x) { 81 return ! _p.fn(x); 82 } 83 84 88 public void accept(net.sf.jga.fn.Visitor v) { 89 if (v instanceof UnaryNegate.Visitor) 90 ((UnaryNegate.Visitor)v).visit(this); 91 else 92 v.visit(this); 93 } 94 95 97 public String toString() { 98 return "UnaryNegate"; 99 } 100 101 103 107 public interface Visitor extends net.sf.jga.fn.Visitor { 108 public void visit(UnaryNegate host); 109 } 110 } 111 | Popular Tags |