net.sf.jga.fn.comparison

Class MaxComp<T>

public class MaxComp<T> extends AbstractBinaryFunctor<T,T,T> implements Serializable

Binary Functor that returns the greater of two object arguments x and y as determined by the given Comparator. If x == y, returns x (somewhat arbitrarily). The behaviour of this class in the presence of null arguments is left to the implementation of the specific Comparator, however it is generally safe to assume that using null arguments will cause a NullPointerException to be thrown.

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceMaxComp.Visitor
Interface for classes that may interpret a MaxComp predicate.
Constructor Summary
MaxComp(Comparator<T> comp)
Builds the MaxComp predicate using the given Comparator
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(MaxComp) method, if it implements the nested Visitor interface.
Tfn(T x, T y)
Returns the greater of two arguments, or the first if they are equal.
Comparator<T>getComparator()
Returns the comparator in use by this functor
StringtoString()

Constructor Detail

MaxComp

public MaxComp(Comparator<T> comp)
Builds the MaxComp predicate using the given Comparator

Throws: IllegalArgumentException if the argument is null

Method Detail

accept

public void accept(Visitor v)
Calls the Visitor's visit(MaxComp) method, if it implements the nested Visitor interface.

fn

public T fn(T x, T y)
Returns the greater of two arguments, or the first if they are equal.

Returns: the greater of two arguments, or the first if they are equal.

getComparator

public Comparator<T> getComparator()
Returns the comparator in use by this functor

Returns: the comparator in use by this functor

toString

public String toString()