Implementation is provided by a set of adaptor objects that implement the Arithmatic interface. Adaptors are provided for all standard Number classes: the six Reference classes in the java.lang package (Byte, Short, Integer, Long, Float, and Double) and the two classes defined in the java.math package (BigInteger and BigDecimal).
To apply the Functors found in this package with user-defined Number
implementations, it is necessary to create and register an implementation of
Arithmetic or IntegerArithmetic. For example, assuming that a
Fraction
class has been defined, support for arithmetic operations
could be provided by
public class FractionMath implements Arithmetic<Fraction> { public Fraction plus (Fraction x, Fraction y) { // implementation omitted } ... }
Before any Functors can be built using the Fraction class, it is necessary to
register the FractionMath implementation with the ArithmeticFactory.
ArithmeticFactory.register(Fraction.class, new FractionMath());