Annotation Type Parameter
A typical use is to derive names for the parameters of user-defined functions.
Here is an example:
public static class MyLeftFunction { public String eval( @Parameter(name = "s") String s, @Parameter(name = "n", optional = true) Integer n) { return s.substring(0, n == null ? 1 : n); } }
The first parameter is named "s" and is mandatory, and the second parameter is named "n" and is optional.
If this annotation is present, it supersedes information that might be
available via
Executable.getParameters()
(JDK 1.8 and above).
If the annotation is not specified, parameters will be named "arg0", "arg1" et cetera, and will be mandatory.
-
Required Element Summary
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Returns whether the parameter is optional.
-
Element Details
-
name
String nameThe name of the parameter.The name is used when the function is called with parameter assignment, for example
foo(x => 1, y => 'a')
. -
optional
boolean optionalReturns whether the parameter is optional.An optional parameter does not need to be specified when you call the function.
If you call a function using positional parameter syntax, you can omit optional parameters on the trailing edge. For example, if you have a function
baz(int a, int b optional, int c, int d optional, int e optional)
then you can callbaz(a, b, c, d, e)
orbaz(a, b, c, d)
orbaz(a, b, c)
but notbaz(a, b)
becausec
is not optional.If you call a function using parameter name assignment syntax, you can omit any parameter that has a default value. For example, you can call
baz(a => 1, e => 5, c => 3)
, omitting optional parametersb
andd
.Currently, the default value used when a parameter is not specified is NULL, and therefore optional parameters must be nullable.
- Default:
false
-