org.mmbase.util.functions
Class NodeFunction<R>

Package class diagram package NodeFunction
java.lang.Object
  extended by org.mmbase.util.functions.AbstractFunction<R>
      extended by org.mmbase.util.functions.NodeFunction<R>
All Implemented Interfaces:
Serializable, Comparable<Function<R>>, Function<R>
Direct Known Subclasses:
CloneNodeFunction, PatternNodeFunctionProvider.PatternNodeFunction

public abstract class NodeFunction<R>
extends AbstractFunction<R>

A NodeFunction represents a function on a node instances of this builder. This means that it always has one implicit node argument. This node-argument needs not be mentioned in the Parameter array of the constructor. If you need to impelment this and like to use MMObjectNodes for the implementation (which would probably make the function unusable in RMMCI), then you could extend MMObjectNodeFunction.

Since:
MMBase-1.8
Version:
$Id: NodeFunction.java 45227 2011-02-16 11:00:53Z michiel $
Author:
Michiel Meeuwissen
See Also:
Node.getFunctionValue(java.lang.String, java.util.List), BeanFunction, Serialized Form

Field Summary
 
Fields inherited from class org.mmbase.util.functions.AbstractFunction
autoReturnType, name, returnType
 
Constructor Summary
NodeFunction(String name, Parameter... def)
           
NodeFunction(String name, Parameter<?>[] def, ReturnType<R> returnType)
           
 
Method Summary
static String getFunctionNameAndFillArgs(String function, List<String> args)
           
protected abstract  R getFunctionValue(Node node, Parameters parameters)
           
static FieldValue getFunctionValue(Node node, String function)
          Utility function, for easy call of function on node by one string.
 R getFunctionValue(Parameters parameters)
          To implement a NodeFunction, you must override getFunctionValue(Node, Parameters).
 R getFunctionValueForNode(Node node, Parameters parameters)
          Just a public wrapper around getFunctionValue(Node, Parameters) (of which we don't want to loosen the scope, because it may be overriden protected).
protected  Node getNode(Parameters parameters)
           
protected static Parameter[] getNodeParameterDef(Parameter... def)
           
 ReturnType<R> getReturnType()
           
 Function<R> newInstance(Node node)
          Returns a new instance of NodeInstanceFunction, which represents an actual Function.
static
<S> NodeFunction<S>
wrap(Function<S> function)
          Tries to convert a certain Function object into a NodeFunction object.
 
Methods inherited from class org.mmbase.util.functions.AbstractFunction
compareTo, createParameters, equals, getDescription, getFunctionValueWithArgs, getFunctionValueWithList, getName, getParameterDefinition, hashCode, setDescription, setParameterDefinition, setReturnType, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeFunction

public NodeFunction(String name,
                    Parameter<?>[] def,
                    ReturnType<R> returnType)

NodeFunction

public NodeFunction(String name,
                    Parameter... def)
Since:
MMBase-1.9
Method Detail

getReturnType

public ReturnType<R> getReturnType()
Specified by:
getReturnType in interface Function<R>
Overrides:
getReturnType in class AbstractFunction<R>
Returns:
The currently set ReturnType, or null if not set already.

getFunctionValue

public static FieldValue getFunctionValue(Node node,
                                          String function)
Utility function, for easy call of function on node by one string.


getFunctionNameAndFillArgs

public static String getFunctionNameAndFillArgs(String function,
                                                List<String> args)

getNodeParameterDef

protected static Parameter[] getNodeParameterDef(Parameter... def)

newInstance

public final Function<R> newInstance(Node node)
Returns a new instance of NodeInstanceFunction, which represents an actual Function.


getFunctionValue

protected abstract R getFunctionValue(Node node,
                                      Parameters parameters)

getFunctionValueForNode

public final R getFunctionValueForNode(Node node,
                                       Parameters parameters)
Just a public wrapper around getFunctionValue(Node, Parameters) (of which we don't want to loosen the scope, because it may be overriden protected).


getNode

protected Node getNode(Parameters parameters)

getFunctionValue

public R getFunctionValue(Parameters parameters)
To implement a NodeFunction, you must override getFunctionValue(Node, Parameters). This one can be overridden if the same function must also be a builder function.

Specified by:
getFunctionValue in interface Function<R>
Specified by:
getFunctionValue in class AbstractFunction<R>
Parameters:
parameters - The parameters for the function. To specify an empty parameter list use Parameters.VOID. Implementors are encouraged to support null too.
Returns:
The function value, which can be of any type compatible to AbstractFunction.getReturnType()
See Also:
AbstractFunction.createParameters()

wrap

public static <S> NodeFunction<S> wrap(Function<S> function)
Tries to convert a certain Function object into a NodeFunction object.

Returns:
function if that was already a NodeFunction, null if it could not be wrapped (No Parameter.NODE parameter), or a new NodeFunction object wrapping function
Since:
MMBase-1.8.5


MMBase2 Bridge 2.0-SNAPSHOT - 2014-09-22T23:05