Interface FunctionArguments
public sealed interface FunctionArguments
A class containing all arguments in a function call.
-
Method Summary
Modifier and TypeMethodDescription<T> T
Gets a specific argument by name.<T> T
getOrDefault
(@NotNull String name, Supplier<T> defaultValue) Gets a specific argument by name, or calculates the default value if no value is found.<T> T
getOrDefault
(@NotNull String name, T defaultValue) Gets a specific argument by name, or a default value if no value is found.names()
Returns all the argument names available in this instance.
-
Method Details
-
get
Gets a specific argument by name.This method automatically conforms to your expected type, to avoid having to cast from Object. Use this method as follows.
Number value = args.get("n"); Boolean value = args.get("b"); Number[] value = args.get("ns"); args.
get("b"); // inline - Type Parameters:
T
- The type to return.- Parameters:
name
- The name of the parameter.- Returns:
- The value present, or null if no value is present.
-
getOrDefault
Gets a specific argument by name, or a default value if no value is found.This method automatically conforms to your expected type, to avoid having to cast from Object. Use this method as follows.
Number value = args.getOrDefault("n", 3.0); boolean value = args.getOrDefault("b", false); args.
getOrDefault("b", () -> false); // inline - Type Parameters:
T
- The type to return.- Parameters:
name
- The name of the parameter.defaultValue
- The default value.- Returns:
- The value present, or the default value if no value is present.
-
getOrDefault
Gets a specific argument by name, or calculates the default value if no value is found.This method automatically conforms to your expected type, to avoid having to cast from Object. Use this method as follows.
Number value = args.getOrDefault("n", () -> 3.0); boolean value = args.getOrDefault("b", () -> false); args.
getOrDefault("b", () -> false); // inline - Type Parameters:
T
- The type to return.- Parameters:
name
- The name of the parameter.defaultValue
- A supplier that calculates the default value if no existing value is found.- Returns:
- The value present, or the calculated default value if no value is present.
-
names
Returns all the argument names available in this instance.- Returns:
- All argument names.
-