net.sf.jga.fn.arithmetic

Class Negate<T>

public class Negate<T extends Number> extends AbstractUnaryFunctor<T,T> implements Serializable

Returns the negative of its numeric argument.

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceNegate.Visitor
Interface for classes that may interpret a Negate functor.
Constructor Summary
Negate(Class c)
Builds Negate functor for the given class.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(Negate) method, if it implements the nested Visitor interface.
Tfn(T x)
Given numeric argument x, returns -x
StringtoString()

Constructor Detail

Negate

public Negate(Class c)
Builds Negate functor for the given class. The class argument must be the same as the generic class argument (when generics are in use) or else a ClassCastException will be thrown when the functor is used.

Throws: IllegalArgumentException if the given class has no Arithmetic implementation registered with the ArithmeticFactory

Method Detail

accept

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

fn

public T fn(T x)
Given numeric argument x, returns -x

Returns: the negative of its numeric argument

toString

public String toString()