AnyLogic
Expand
Font size
All Implemented Interfaces:
Serializable

public class CodeValue
extends Object
implements Serializable
Class containing some executable action / evaluatable expression code inside.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

ConstructorDescription
CodeValue(String code)
Creates new expression / action descriptor

Method Summary

Modifier and TypeMethodDescription
<T> Texecute(CodeValueExecutor context, Class<T> returnType, Object... argDescriptors) 
<T> Texecute(CodeValueExecutor context, Object... argDescriptors)
Executes/evaluates the code value, e.g.
StringgetCode()
Returns the original code string contained in this object

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

CodeValue

public CodeValue(String code)
Creates new expression / action descriptor
Parameters:
owner - agent / experiment context, this action will be executed in
code - java code of expression / action

Method Details

execute

public <T> T execute(CodeValueExecutor context,
 Object... argDescriptors)
Executes/evaluates the code value, e.g. when the code value "exponential( 10 )" will result in some number chosen using exponential distribution.
If provided, uses the given arguments, specified in the form of pair: name, value. In the following example:
codeValue.execute( this, "agent", agent, "index", i - 1 )
the code will operate with variables agent and index of types Agent and Integer
Parameters:
argDescriptors - array of pairs: argName1, argValue1, argName2, argValue2, ...
Returns:
evaluated expression result (if this is an expression, not action)

execute

public <T> T execute(CodeValueExecutor context,
 Class<T> returnType,
 Object... argDescriptors)

getCode

public String getCode()
Returns the original code string contained in this object
Returns:
java code of expression / action