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

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

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

Base abstract class for functions returning null 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 AbstractNullAsNullFunction()
           
 
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 nullAsNullExecute(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

AbstractNullAsNullFunction

protected AbstractNullAsNullFunction()
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

nullAsNullExecute

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

Executes the function knowing that the input parameter (the target object) is not null. If the target object is null, the function will return null instead of calling this method.

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


Copyright © 2012 The OP4J team. All Rights Reserved.