Previous | UML Classes | Table of Contents | UML Packages | Next |
An operation is a behavioral feature of a classifier that specifies the name, type, parameters, and constraints for invoking
an associated behavior.
•
BehavioralFeature (from Kernel ) on page 47
An operation is a behavioral feature of a classifier that specifies the name, type, parameters, and constraints for invoking
an associated behavior.
• /isOrdered : Boolean Specifies whether the return parameter is ordered or not, if present. This is derived.
• isQuery : Boolean Specifies whether an execution of the BehavioralFeature leaves the state of the system unchanged (isQuery=true) or whether side effects may occur (isQuery=false). The default value is false.
• /isUnique : Boolean Specifies whether the return parameter is unique or not, if present. This is derived.
• /lower : Integer[0..1] Specifies the lower multiplicity of the return parameter, if present. This is derived.
• /upper : UnlimitedNatural[0..1] Specifies the upper multiplicity of the return parameter, if present. This is derived.
• class : Class [0..1] The class that owns this operation. Subsets RedefinableElement ::redefinitionContext, NamedElement ::namespace
and Feature::featuringClassifier
• bodyCondition: Constraint[0..1] An optional Constraint on the result values of an invocation of this Operation. Subsets
Namespace ::ownedRule
Issue Editorial change: make ‘ownedParameter’ ordered
• ownedParameter: Parameter[*] {ordered} Specifies the parameters owned by this Operation. Redefines BehavioralFeature::ownedParameter.
• postcondition: Constraint[*] An optional set of Constraints specifying the state of the system when the Operation is completed. Subsets Namespace ::ownedRule.
• precondition: Constraint[*] An optional set of Constraints on the state of the system when the Operation is invoked. Subsets Namespace ::ownedRule
• raisedException: Type[*] References the Types representing exceptions that may be raised during an invocation of this operation. Redefines Basic::Operation.raisedException and BehavioralFeature::raisedException.
• redefinedOperation: Operation[*] References the Operations that are redefined by this Operation. Subsets
RedefinableElement ::redefinedElement
• /type: Type[0..1] Specifies the return result of the operation, if present. This is a derived value.
Package Interfaces
• interface: Interface [0..1] The Interface that owns this Operation. (Subsets RedefinableElement ::redefinitionContext, NamedElement ::namespace
and Feature::featuringClassifier)
[1] An operation can have at most one return parameter (i.e., an owned parameter with the direction set to ‘return’).
ownedParameter->select(par | par.direction = #return)->size() <= 1
[2] If this operation has a return parameter, isOrdered equals the value of isOrdered for that parameter. Otherwise isOrdered
is false.
isOrdered = if returnResult()->notEmpty() then returnResult()->any().isOrdered else false endif
[3] If this operation has a return parameter, isUnique equals the value of isUnique for that parameter. Otherwise isUnique
is
true.isUnique = if returnResult()->notEmpty() then returnResult()->any().isUnique else true endif
[4] If this operation has a return parameter, lower equals the value of lower for that parameter. Otherwise lower is not defined.
lower = if returnResult()->notEmpty() then returnResult()->any().lower else Set{} endif
[5] If this operation has a return parameter, upper equals the value of upper for that parameter. Otherwise upper is not defined.
upper = if returnResult()->notEmpty() then returnResult()->any().upper else Set{} endif
[6] If this operation has a return parameter, type equals the value of type for that parameter. Otherwise type is not defined.
type = if returnResult()->notEmpty() then returnResult()->any().type else Set{} endif
[7] A bodyCondition can only be specified for a query operation.
bodyCondition->notEmpty() implies isQuery
[1] The query isConsistentWith() specifies, for any two Operations in a context in which redefinition is possible, whether
redefinition would be logically consistent. A redefining operation is consistent with a redefined operation if it has the
same number of owned parameters, and the type of each owned parameter conforms to the type of the corresponding redefined
parameter.
A redefining operation is consistent with a redefined operation if it has the same number of formal parameters, the same
number of return results, and the type of each formal parameter and return result conforms to the type of the
corresponding redefined parameter or return result.
Operation::isConsistentWith(redefinee: RedefinableElement ): Boolean;
pre: redefinee.isRedefinitionContextValid(self)
isConsistentWith = (redefinee.oclIsKindOf(Operation) and
let op: Operation = redefinee.oclAsType(Operation) in
self.ownedParameter.size() = op.ownedParameter.size() and
forAll(i | op.ownedParameter[i].type.conformsTo(self.ownedParameter[i].type))
)
[2] The query returnResult() returns the set containing the return parameter of the Operation if one exists, otherwise, it
returns an empty set.
Operation::returnResult() : Set(Parameter);
returnResult = ownedParameter->select (par | par.direction = #return)
An operation is invoked on an instance of the classifier for which the operation is a feature.
The preconditions for an operation define conditions that must be true when the operation is invoked. These preconditions
may be assumed by an implementation of this operation.
The postconditions for an operation define conditions that will be true when the invocation of the operation completes successfully,
assuming the preconditions were satisfied. These postconditions must be satisfied by any implementation of the operation.
The bodyCondition for an operation constrains the return result. The bodyCondition differs from postconditions in that the
bodyCondition may be overridden when an operation is redefined, whereas postconditions can only be added during redefinition.
An operation may raise an exception during its invocation. When an exception is raised, it should not be assumed that the
postconditions or bodyCondition of the operation are satisfied.
An operation may be redefined in a specialization of the featured classifier. This redefinition may specialize the types of
the owned parameters, add new preconditions or postconditions, add new raised exceptions, or otherwise refine the specification
of the operation.
Each operation states whether or not its application will modify the state of the instance or any other element in the model
(isQuery).
An operation may be owned by and in the namespace of a class that provides the context for its possible redefinition.
The behavior of an invocation of an operation when a precondition is not satisfied is a semantic variation point. When operations
are redefined in a specialization, rules regarding invariance, covariance, or contravariance of types and preconditions determine
whether the specialized classifier is substitutable for its more general parent. Such rules constitute semantic variation
points with respect to redefinition of operations.
Issue 8298 -add qualifying phrase in front 8228 -add brackets to BNF
If shown in a diagram, an operation is shown as a text string of the form:
[<visibility>] <name> ‘(‘ [<parameter-list>] ‘)’ [‘:’ [<return-type>] [‘{‘ <oper-property> [‘,’ <oper-property>]* ‘}’]]
where:
•
<visibility>
is the visibility of the operation (See VisibilityKind (from Kernel ) on page 141).
<visibility> ::= ‘+’ | ‘-‘ | ‘#’ | ‘~’
•
<name> is the name of the operation.
•
<return-type> is the type of the return result parameter if the operation has one defined.
•
<oper-property> indicates the properties of the operation.
<oper-property> ::= ‘redefines’ <oper-name> | ‘query’ | ‘ordered’ | ‘unique’ | <oper-constraint>
where:
• redefines <oper-name> means that the operation redefines an inherited operation identified by <oper-name>.
• query means that the operation does not change the state of the system.• ordered means that the values of the return parameter are ordered.
• unique means that the values returned by the parameter have no duplicates.
• <oper-constraint> is a constraint that applies to the operation.
• <parameter-list> is a list of parameters of the operation in the following format:
<parameter-list> ::= <parameter> [‘,’<parameter>]* <parameter> ::= [<direction>] <parameter-name> ‘:’ <type-expression> [‘[‘<multiplicity>’]’]
[‘=’ <default>] [‘{‘ <parm-property> [‘,’ <parm-property>]* ‘}’]
where:
• <direction> ::= ‘in’ | ‘out’ | ‘inout’ (defaults to ‘in’ if omitted).
• <parameter-name> is the name of the parameter.
• <type-expression> is an expression that specifies the type of the parameter.
• <multiplicity> is the multiplicity of the parameter . (See MultiplicityElement (from Kernel ) on page 96).
• <default> is an expression that defines the value specification for the default value of the parameter.
• <parm-property> indicates additional property values that apply to the parameter.
The parameter list can be suppressed. The return result of the operation can be expressed as a return parameter, or as the
type of the operation. For example:
toString(return : String)
means the same thing as
toString() : String
An operation name typically begins with a lowercase letter.
display ()-hide ()+createWindow (location: Coordinates, container: Container [0..1]): Window+toString (): String