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

Object
  extended by org.op4j.functions.Function<T,R>
      extended by org.op4j.functions.AbstractNotNullFunction<T,R>
All Implemented Interfaces:
IFunction<T,R>

public abstract class AbstractNotNullFunction<T,R>
extends Function<T,R>

Base abstract class for functions throwing an IllegalArgumentException if the target object is null.

This class can be extended by the user when creating his/her own functions, if desired.

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
protected AbstractNotNullFunction()
           
 
Method Summary
 R execute(T input, ExecCtx ctx)
           Executes the function on the current target object, which is passed as the input parameter.
protected abstract  R notNullExecute(T input, ExecCtx ctx)
           Executes the function knowing that the input parameter (the target object) is not null.
 
Methods inherited from class org.op4j.functions.Function
execute
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNotNullFunction

protected AbstractNotNullFunction()
Method Detail

execute

public final R execute(T input,
                       ExecCtx ctx)
                throws Exception
Description copied from interface: IFunction

Executes the function on the current target object, which is passed as the input parameter. The ExecCtx parameter provides some metadata related to the execution, like the index in an iteration.

The execution of a function can throw any exception.

If you intend to call the execute method directly on any of your functions (outside an op4j expression), you might prefer using Function.execute(Object) instead.

Parameters:
input - the target object on which the function is to be executed
ctx - the context (metadata) for the function execution
Returns:
the result of executing the function
Throws:
Exception

notNullExecute

protected abstract R notNullExecute(T input,
                                    ExecCtx ctx)
                             throws Exception

Executes the function knowing that the input parameter (the target object) is not null. An IllegalArgumentException will have been thrown in the target was null, before this method is called.

Parameters:
input - the target object
ctx - the execution context
Returns:
the result of the function execution
Throws:
Exception


Copyright © 2012 The OP4J team. All Rights Reserved.