Class Multiplier

java.lang.Object
  |
  +--Multiplier
All Implemented Interfaces:
Function2

class Multiplier
extends java.lang.Object
implements Function2

A Multiplier is a Function2 object that can be used to multiply a pair of Numbers. If both Numbers are Long or Integer, it returns a Long. Otherwise it returns a Double.


Constructor Summary
(package private) Multiplier()
          Create a Multiplier with a specific scale factor.
 
Method Summary
 java.lang.Object apply(java.lang.Object x, java.lang.Object y)
          Apply this Multiplier object to two Objects, both of which should be Numbers.
static java.lang.Number multiply(java.lang.Object x, java.lang.Object y)
          Multiply two Objects, both of which should be Numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Multiplier

Multiplier()
Create a Multiplier with a specific scale factor.

Method Detail

apply

public java.lang.Object apply(java.lang.Object x,
                              java.lang.Object y)
Apply this Multiplier object to two Objects, both of which should be Numbers. If they are not numbers, a ClassCastException will be thrown.

Specified by:
apply in interface Function2
Parameters:
x - the first argument of this function
y - the second argument of this function
Returns:
a Number containing the product of the arguments. If the arguments are both Integer or Long, it returns a Long. Otherwise it returns a Double.

multiply

public static java.lang.Number multiply(java.lang.Object x,
                                        java.lang.Object y)
Multiply two Objects, both of which should be Numbers. If they are not numbers, a ClassCastException will be thrown.

Parameters:
x - the first argument of this function
y - the second argument of this function
Returns:
a Number containing the product of the arguments. If the arguments are both Integer or Long, it returns a Long. Otherwise it returns a Double.