org.op4j.functions
Class Function<T,R>

Object
  extended by org.op4j.functions.Function<T,R>
All Implemented Interfaces:
IFunction<T,R>
Direct Known Subclasses:
AbstractNotNullFunction, AbstractNullAsNullFunction, Call, ExpressionFunction, Get, MapBuilder

public abstract class Function<T,R>
extends Object
implements IFunction<T,R>

Base abstract implementation for the IFunction interface, providing a useful execute(Object) method, easier to use than IFunction.execute(Object, ExecCtx).

Function<T,R> means that the function receives an object of type T (called target) and returns an object of type R.

You should consider extending this class for every function class you write (except for anonymous ones). This will allow you to execute the function without passing a context to the execution method and without having to enclose your call inside a try...catch statement.

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
protected Function()
           
 
Method Summary
 R execute(T input)
           Executes the current function on the target object.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.op4j.functions.IFunction
execute
 

Constructor Detail

Function

protected Function()
Method Detail

execute

public R execute(T input)

Executes the current function on the target object. The target object is passed as the input parameter.

Should any exceptions raise during execution, they will be encapsulated in an unchecked ExecutionException exception.

Parameters:
input - the target object.
Returns:
the result of executing the function


Copyright © 2012 The OP4J team. All Rights Reserved.