de.cm.frw.core.fun.impl
Class NUM.Unary

java.lang.Object
  extended by de.cm.frw.core.fun.impl.Function
      extended by de.cm.frw.core.fun.impl.NUM.Unary
Enclosing class:
NUM

public abstract static class NUM.Unary
extends Function

Class to simplify the definition of numerical with one argument.

Author:
cm

Nested Class Summary
 
Nested classes/interfaces inherited from class de.cm.frw.core.fun.impl.Function
Function.InvalidArguments
 
Method Summary
 void checkArguments(java.util.Collection args)
          Override this method to check conditions on the arguments (like types) passed to the function in apply before the operate method is called.
 java.lang.Object operate(java.lang.Object[] operands)
          Override this to implement the actual operation realized by this function.
 
Methods inherited from class de.cm.frw.core.fun.impl.Function
apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, apply, arity, box, box, box, box, box, box, box, box, box, box, box, box, box, box, box, is, main, map, map, reduce, unbox, val
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkArguments

public void checkArguments(java.util.Collection args)
                    throws Function.InvalidArguments
Description copied from class: Function
Override this method to check conditions on the arguments (like types) passed to the function in apply before the operate method is called. Throw the declared exception with a meaningful message when condition are not met. Note: Number of arguments < arity is checked before this is called to have enough arguments to operate on, however if more is no good, check it here ... Default implementation does nothing.

Overrides:
checkArguments in class Function
Throws:
Function.InvalidArguments

operate

public java.lang.Object operate(java.lang.Object[] operands)
                         throws Function.InvalidArguments
Description copied from class: Function
Override this to implement the actual operation realized by this function.

Remember to document the number and types of the operands and any other conditions for running the operate method. Or implement checkArguments instead.

Default implementation returns first argument passed in, realizing sort of an unary identity function.

Overrides:
operate in class Function
Parameters:
operands - An array of the arguments that where passed to apply
Returns:
An object as a result of the operation
Throws:
Function.InvalidArguments - when you implement it to do so ...