Package org.moeaframework.util.tree
Class Define
java.lang.Object
org.moeaframework.util.tree.Node
org.moeaframework.util.tree.Define
- All Implemented Interfaces:
Serializable
The node for defining a callable, named function. Once a named function is defined, it can be invoked using
Call
. The behavior (body) of this function can be mutated. For immutable functions, see Lambda
.- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a new node for defining a function that takes no arguments.Constructs a new node for defining a function that takes a user-defined number of arguments.Constructs a new node for defining a function that takes one argument.Define
(String functionName, Class<?> returnType, String name1, Class<?> type1, String name2, Class<?> type2) Constructs a new node for defining a function that takes two arguments. -
Method Summary
Modifier and TypeMethodDescriptioncopyNode()
Returns a copy of this node, but without any children or parents assigned.evaluate
(Environment environment) Evaluates this node in the context of the specified environment.Returns the name of this function.String[]
Returns the names of the arguments to this function.Class<?>[]
Returns the types of the arguments to this function.toString()
Methods inherited from class org.moeaframework.util.tree.Node
copyTree, getArgument, getArgumentType, getDepth, getFunctionAt, getFunctionAt, getMaximumHeight, getMinimumHeight, getNodeAt, getNodeAt, getNodeAt, getNumberOfArguments, getNumberOfFunctions, getNumberOfFunctions, getNumberOfNodes, getNumberOfNodes, getNumberOfNodes, getNumberOfTerminals, getNumberOfTerminals, getParent, getReturnType, getTerminalAt, getTerminalAt, isFixed, isTerminal, isValid, setArgument, setFixed, setFixedTree, size
-
Constructor Details
-
Define
Constructs a new node for defining a function that takes no arguments.- Parameters:
functionName
- the name of the functionreturnType
- the return type of the function
-
Define
Constructs a new node for defining a function that takes one argument.- Parameters:
functionName
- the name of the functionreturnType
- the return type of the functionvariableName
- the name of the argumentvariableType
- the type of the argument
-
Define
public Define(String functionName, Class<?> returnType, String name1, Class<?> type1, String name2, Class<?> type2) Constructs a new node for defining a function that takes two arguments.- Parameters:
functionName
- the name of the functionreturnType
- the return type of the functionname1
- the name of the first argumenttype1
- the type of the first argumentname2
- the name of the second argumenttype2
- the type of the second argument
-
Define
public Define(String functionName, Class<?> returnType, String[] variableNames, Class<?>[] variableTypes) Constructs a new node for defining a function that takes a user-defined number of arguments.- Parameters:
functionName
- the name of the functionreturnType
- the return type of the functionvariableNames
- the names of the arguments to the functionvariableTypes
- the types of the arguments to the function
-
-
Method Details
-
getFunctionName
Returns the name of this function.- Returns:
- the name of this function
-
getVariableNames
Returns the names of the arguments to this function.- Returns:
- the names of the arguments to this function
-
getVariableTypes
Returns the types of the arguments to this function.- Returns:
- the types of the arguments to this function
-
copyNode
Description copied from class:Node
Returns a copy of this node, but without any children or parents assigned. -
evaluate
Description copied from class:Node
Evaluates this node in the context of the specified environment. -
toString
-