1 33 package net.sf.jga.fn.comparison; 34 35 import java.util.Comparator ; 36 import net.sf.jga.fn.BinaryPredicate; 37 import net.sf.jga.util.ComparableComparator; 38 39 56 57 public class Greater<T> extends BinaryPredicate<T,T> { 58 59 static final long serialVersionUID = 8666386929519645339L; 60 61 private Comparator <? super T> _comp; 63 64 68 public Greater(Comparator <? super T> comp) { 69 if (comp == null) { 70 throw new IllegalArgumentException ("Comparator may not be null"); 71 } 72 73 _comp = comp; 74 } 75 76 80 public Comparator <? super T> getComparator() { return _comp; } 81 82 84 90 public Boolean fn(T x, T y) { 91 return Boolean.valueOf(getComparator().compare(x, y) > 0); 92 } 93 94 98 public void accept(net.sf.jga.fn.Visitor v) { 99 if (v instanceof Greater.Visitor) 100 ((Greater.Visitor)v).visit(this); 101 else 102 v.visit(this); 103 } 104 105 107 public String toString() { 108 return "Greater"; 109 } 110 111 113 116 public interface Visitor extends net.sf.jga.fn.Visitor { 117 public void visit(Greater host); 118 } 119 120 125 126 static public class Comparable<T extends java.lang.Comparable <? super T>> 127 extends Greater<T> 128 { 129 static final long serialVersionUID = 5187118104447673700L; 130 public Comparable() { super(new ComparableComparator<T>()); } 131 } 132 } 133 134 | Popular Tags |