|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.functions.AbstractFunction<R>
public abstract class AbstractFunction<R>
An abstract representation of a piece of functionality (a 'function'). A function has a name, a
return type, and a parameter-definition (which is a 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| Field Summary | |
|---|---|
protected boolean |
autoReturnType
|
protected String |
name
|
protected ReturnType<R> |
returnType
|
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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 |
getFunctionValueWithArgs(Object... parameters)
A 'varargs' version of getFunctionValueWithList. |
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final String name
protected ReturnType<R> returnType
protected boolean autoReturnType
| Constructor Detail |
|---|
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)
public AbstractFunction(String name,
Parameter<?>... def)
getFunctionValue(Parameters).
| Method Detail |
|---|
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 final R getFunctionValueWithArgs(Object... parameters)
FunctiongetFunctionValueWithList.
getFunctionValueWithArgs in interface Function<R>public void setDescription(String description)
setDescription in interface Function<R>public String getDescription()
getDescription in interface Function<R>setDescription(String)public String getName()
getName in interface Function<R>nullpublic 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 boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class ObjectObject.hashCode()public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||