<Default Package>
Type action < TYPE... >


Type Parameters:
TYPE... - Argument types and return value.
Callable references to actions.

In addition to defining an action, you can define a variable whose type is action. This lets you assign an action to an action variable of the same action type. An action is of the same type as an action variable if they have the same argument list (the same types in the same order) and return type (if any).

The syntax for declaring an action variable is:
action<[type1[, type2]...]> [returns returntype] name;
Defining action type variables is useful for invoking an action and for passing an action to another action.

You can use an action variable anywhere that you can use a sequence or dictionary variable. For example, you can You must initialize an action variable before you try to invoke it.

You cannot send, route, emit, or enqueue an event that contains an action type member.

When an action is a non-static member of an event, the behavior of the action depends on the instance of the event that the action is called on. Consequently, it can be handy to bind an action variable value with a particular event instance. This is referred to as creating a closure.

An action variable is a potentially-cyclic type — a type that may directly or indirectly refer to itself.

When the correlator clones a value that contains an action variable, or copies a value that contains an action variable into a new monitor because of a spawn operation, the correlator preserves the structure inside the value. This means that if two things are references to the same object in the original value, they will be references to the same object in the copy. This includes objects referred to by closures that have been assigned to action variables.

The default value of an action type is an empty action; attempting to call an empty action will throw NullPointerException.

When you call toString() on an object that contains an action variable, the result is the name of the method or action in the action variable. If the action variable contains a closure, the toString() method outputs the bound value followed by the name of the action or method being called on the value. When the toString() method encounters an empty action variable, the output is new followed by the type.

The only operations that you can perform on an action variable are to call it or use it in an ifpresent statement to determine if it is empty or not. You can call an action in the normal way by passing a set of parameters in parentheses after an expression that evaluates to the action variable.

An action variable cannot be a key in a dictionary. An event that contains an action field cannot be a key in a dictionary.

action variables have no methods, they can only be invoked.