public abstract class AbstractFunction<R> extends Object implements Function<R>, Comparable<Function<R>>, Serializable
Parameter array).
The goal of a Function object is to call its getFunctionValue(Parameters) method, which
executes it, given the specified parameters.
The Parameter definition and ReturnType can be passed into your implementation using the constructor. The
implementation must be provided by implementing getFunctionValue(org.mmbase.util.functions.Parameters).Parameter,
Parameters,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoReturnType |
protected String |
name |
protected ReturnType<R> |
returnType |
| Constructor and Description |
|---|
AbstractFunction(String name,
Parameter<?>... def)
Determines the ReturnType automaticly using the return type of
getFunctionValue(Parameters). |
AbstractFunction(String name,
Parameter<?>[] def,
ReturnType<R> returnType)
Constructor for Function objects.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Function<R> fun) |
Parameters |
createParameters()
Creates an empty 'Parameters' object for you, which you have to fill and feed back to getFunctionValue
|
boolean |
equals(Object o) |
String |
getDescription() |
abstract R |
getFunctionValue(Parameters parameters)
Executes the defined function supplying the given arguments.
|
R |
getFunctionValueWithList(List<?> parameters)
Executes the defined function supplying the given List of arguments.
|
String |
getName()
A function must have a name.
|
Parameter<?>[] |
getParameterDefinition() |
ReturnType<R> |
getReturnType() |
int |
hashCode() |
void |
setDescription(String description)
For documentational purposes a function object needs a description too.
|
void |
setParameterDefinition(Parameter<?>[] params)
A function object is of no use, as long as it lacks a definition.
|
void |
setReturnType(ReturnType<R> type)
Sets the ReturnType for this function if not set already.
|
String |
toString() |
protected final String name
protected ReturnType<R> returnType
protected boolean autoReturnType
public AbstractFunction(String name, Parameter<?>[] def, ReturnType<R> returnType)
name - Every function must have a namedef - Every function must have a parameter definition. It can be left null and then filled later by setParameterDefinition(org.mmbase.util.functions.Parameter<?>[])returnType - Every function must also specify its return type. It can be left null and then filled later by setReturnType(org.mmbase.util.functions.ReturnType<R>)public AbstractFunction(String name, Parameter<?>... def)
getFunctionValue(Parameters).public Parameters createParameters()
createParameters in interface Function<R>getFunctionValue(Parameters)public abstract R getFunctionValue(Parameters parameters)
getFunctionValue in interface Function<R>parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.
Implementors are encouraged to support null too.getReturnType()createParameters()public final R getFunctionValueWithList(List<?> parameters)
getFunctionValue(Parameters).getFunctionValueWithList in interface Function<R>parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID.getReturnType()public void setDescription(String description)
setDescription in interface Function<R>public String getDescription()
getDescription in interface Function<R>setDescription(String)public String getName()
public Parameter<?>[] getParameterDefinition()
getParameterDefinition in interface Function<R>null if not set already.public void setParameterDefinition(Parameter<?>[] params)
setParameterDefinition in interface Function<R>params - An array of Parameter objects.IllegalStateException - if there was already set a parameter defintion for this function object.public ReturnType<R> getReturnType()
getReturnType in interface Function<R>null if not set already.public void setReturnType(ReturnType<R> type)
setReturnType in interface Function<R>type - A ReturnType object. For void functions that could be ReturnType.VOID.IllegalStateException - if there was already set a return type for this function object.public int compareTo(Function<R> fun)
compareTo in interface Comparable<Function<R>>public int hashCode()
hashCode in class ObjectObject.hashCode()MMBase 1.9-SNAPSHOT - ${javadoctimestamp}