Package ortus.boxlang.runtime.util
Class ArgumentUtil
java.lang.Object
ortus.boxlang.runtime.util.ArgumentUtil
Represents an argument to a function or BIF
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ArgumentsScopecreateArgumentsScope(IBoxContext context, Object[] positionalArguments) Create a generic arguments scope from the positional argumentsstatic ArgumentsScopecreateArgumentsScope(IBoxContext context, Object[] positionalArguments, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from the positional argumentsstatic ArgumentsScopecreateArgumentsScope(IBoxContext context, Map<Key, Object> namedArguments) Create a generic arguments scope from the named argumentsstatic ArgumentsScopecreateArgumentsScope(IBoxContext context, Map<Key, Object> namedArguments, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from the named argumentsstatic ArgumentsScopecreateArgumentsScope(IBoxContext context, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from no argumentsstatic ObjectensureArgumentType(IBoxContext context, Key name, Object value, String type, Key functionName) Ensure the argument is the correct typemapArgumentsToDeclaredArguments(Map<Key, Object> args, Argument[] declaredArguments) Map the arguments to the declared arguments by positionpositionalToMap(Object... args) Convert positional arguments to a map of key/value pairs
-
Constructor Details
-
ArgumentUtil
public ArgumentUtil()
-
-
Method Details
-
createArgumentsScope
public static ArgumentsScope createArgumentsScope(IBoxContext context, Object[] positionalArguments, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from the positional arguments- Parameters:
context- The context of the executionpositionalArguments- The positional argumentsarguments- The declared argumentsscope- The scope to add the arguments tofunctionName- The name of the function- Returns:
- The arguments scope
-
createArgumentsScope
public static ArgumentsScope createArgumentsScope(IBoxContext context, Map<Key, Object> namedArguments, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from the named arguments- Parameters:
context- The context of the executionnamedArguments- The named argumentsarguments- The declared argumentsscope- The scope to add the arguments tofunctionName- The name of the function- Returns:
- The arguments scope
-
createArgumentsScope
public static ArgumentsScope createArgumentsScope(IBoxContext context, Object[] positionalArguments) Create a generic arguments scope from the positional arguments- Parameters:
context- The context of the executionpositionalArguments- The positional arguments- Returns:
- The arguments scope
-
createArgumentsScope
public static ArgumentsScope createArgumentsScope(IBoxContext context, Map<Key, Object> namedArguments) Create a generic arguments scope from the named arguments- Parameters:
context- The context of the executionnamedArguments- The named arguments- Returns:
- The arguments scope
-
createArgumentsScope
public static ArgumentsScope createArgumentsScope(IBoxContext context, Argument[] arguments, ArgumentsScope scope, Key functionName) Create an arguments scope from no arguments- Parameters:
context- The context of the executionarguments- The declared argumentsscope- The scope to add the arguments tofunctionName- The name of the function- Returns:
- The arguments scope
-
ensureArgumentType
public static Object ensureArgumentType(IBoxContext context, Key name, Object value, String type, Key functionName) Ensure the argument is the correct type- Parameters:
context- The context of the executionname- The name of the argumentvalue- The value of the argumenttype- The type of the argumentfunctionName- The name of the function- Returns:
- The value of the argument
-
positionalToMap
Convert positional arguments to a map of key/value pairs- Parameters:
args- The positional arguments- Returns:
- The map of key/value pairs
-
mapArgumentsToDeclaredArguments
public static Map<Key,Object> mapArgumentsToDeclaredArguments(Map<Key, Object> args, Argument[] declaredArguments) Map the arguments to the declared arguments by position- Parameters:
args- The arguments to map. Each key is the position of the argumentdeclaredArguments- The declared arguments- Returns:
- The mapped arguments, if any.
-