ABSTRACT operator
The ABSTRACT operator creates an abstract action.
Syntax
ABSTRACT [type [exclusionType] [order]] [FULL] [(argClassName1, ..., argClassNameN)] [returnClassName [(returnArgClassName1, ..., returnArgClassNameM)]]
Description
The ABSTRACT operator creates an abstract action. Its implementations are added later by ACTION+ statements. Depending on the selected type, the platform builds from them the behavior of a branch operator or a sequence operator.
The ABSTRACT operator is a context-independent action operator, so it can only be used in the ACTION statement.
Parameters
-
typeOption. Possible values:
CASE- the explicit conditional form of the abstract action. The selection condition of each implementation is defined in the correspondingACTION+statement using theWHENblock.MULTI- a polymorphic form of the abstract action. An implementation is selected when the current arguments are compatible with its signature.LIST- the sequential form of the abstract action. In this form all implementations are executed one after another.
If this option is omitted,
MULTIis used by default. -
exclusionTypeOption. It specifies the type of mutual exclusion. Possible values:
EXCLUSIVE- the mutually exclusive mode for theCASEandMULTIforms. In this mode, for each set of arguments there must be at most one matching implementation.OVERRIDE- the mode for theCASEandMULTIforms in which several implementations may match simultaneously.
Used only with
CASEorMULTI. ForCASE,OVERRIDEis used by default; forMULTI,EXCLUSIVEis used by default. -
orderOption. Possible values:
FIRST- for theCASEandMULTIforms withOVERRIDE, new implementations are added to the beginning of the list, so the last added matching implementation is executed. For theLISTform, it sets the execution order reverse to the addition order. If this value is not specified afterOVERRIDE, it is used by default.LAST- for theCASEandMULTIforms withOVERRIDE, new implementations are added to the end of the list, so the first added matching implementation is executed. For theLISTform, it sets the execution order equal to the addition order and is used by default.
Used either after
OVERRIDEfor theCASEandMULTIforms or afterLIST. -
FULLKeyword. If specified, the platform automatically checks the completeness of implementations: for all descendants of the argument classes there must be at least one applicable implementation, or exactly one if the conditions are mutually exclusive.
-
argClassName1, ..., argClassNameNList of class names of action arguments. Each name is defined by a class ID. The list may be empty. If the list is omitted, the parameter classes are taken from the
ACTIONstatement in which theABSTRACToperator is used. -
returnClassNameName of the class of the value returned by the action. It is defined by a class ID. If this parameter is specified, the abstract action is declared as an action with a result.
-
returnArgClassName1, ..., returnArgClassNameMList of class names of the additional parameters on which the returned value depends. It is used when the action returns not a single value, but a set of values over those parameters. Each name is defined by a class ID. The list may be empty.
Examples
exportXls 'Export to Excel' ABSTRACT CASE OVERRIDE LAST (Order);
exportXls (Order o) + WHEN name(currency(o)) == 'USD' THEN {
MESSAGE 'Export USD not implemented';
}
CLASS ABSTRACT Task;
run 'Execute' ABSTRACT MULTI EXCLUSIVE FULL (Task);
CLASS Task1 : Task;
name = DATA STRING[100] (Task);
run (Task1 t) + {
MESSAGE 'Run Task1 ' + name(t);
}
onStarted ABSTRACT LIST ();
onStarted () + {
MESSAGE 'Preparing data';
}
onStarted () + {
MESSAGE 'Starting handlers';
}
CLASS Issue;
CLASS Language;
localizedTitle = DATA STRING[100] (Issue, Language);
getLocalizedTitle(Issue issue) ABSTRACT STRING[100] (Language);
getLocalizedTitle (Issue issue) + {
FOR Language l IS Language DO
RETURN localizedTitle(issue, l);
}