8.3.9 OCL元类上的额外操作

在章节“抽象语法”、“具体语法和“在UML模型中Ocl表达式的使用”中使用了OCL元类上的许多额外操作。它们在本节进行定义。前一节定义UML元类上的额外操作。

OclExpression

如下操作为预定义的asSet()返回一个操作调用表达式,它以self表达式为自己的源。

context OclExpression::withAsSet() : OperationCallExp
post: result.name = ‘asSet’
post: result.argument->isEmpty()
post: result.source = self

TupleType

Tuple上附加了一个额外的类操作来返回一个新的元组。元组类型的名称在抽象语法部分已经定义了,此处不再赘述。

context TupleType::make(atts : Sequence(Property)) : TupleType
post: Sequence{1...atts->size()}->forAll(i | result.ownedAttribute.at(i).cmpSlots(atts.at(i))

Variable

Variable上附加了一个额外操作来返回相应的参数。

context Variable::asParameter() : Parameter
post: result.name = self.name
post: result.direction = ParameterDirectionKind::in
post: result.type = self.type

另外一个操作是返回相应的属性。

context Variable::asProperty() : Attribute
post: result.name         = self.name
post: result.type         = self.type
upperValue                = 1
post: result.lowerValue   = 1
post: result.isOrdered    = true
post: result.isStatic     = false
post: result.visibility   = VisibilityKind::private
post: result.constraint.specification.bodyExpression = self.initExpression

results matching ""

    No results matching ""