Java Reference
In-Depth Information
Disjunction
Another option when structuring mappings is to specify several mappings from
which the first that satisfies its guard conditions (type and
when
clause) is exe-
cuted. This is done by specifying a list of mappings after the
disjuncts
key-
word in the mapping declaration.
During execution, each guard is executed in a series until one is satisfied. The
first successful disjuncted mapping is executed. If none of those listed satisfies the
conditions,
null
is returned. Following is an example adopted from the specifi-
cation, for illustration:
mapping
uml::Feature::convertFeature () : java::Element
disjuncts
convertAttribute, convertOperation, convertConstructor {}
mapping
uml::Attribute::convertAttribute : java::Field {
name := self.name;
}
mapping
uml::Operation::convertConstructor : java::Constructor
when
{self.name = self.namespace.name} {
name := self.name;
}
mapping
uml::Operation::convertOperation : java::Constructor
when
{self.name <> self.namespace.name} {
name := self.name;
}
Although I've mentioned
mapping
and
query
operations, I've not made a for-
mal distinction between these two constructs. According to the QVT specifica-
tion, a query is a special kind of
helper
operation. But unlike a
query
, a
helper
may
have side effects on the parameters passed into it.
Queries are intended to simplify expression writing in mapping operations
because complex queries are not required to be implemented within an expres-
sion. The main restriction on queries is that they cannot create or update object
instances, other than for predefined and intermediate types. A query is an oper-
ation that has no side effects.
A mapping operation does not return a new instance of the specified model
object for a given input instance upon subsequent invocations, based on its trace
model. Instead, it returns a reference to the previously mapped instance. With a
helper operation, the result is always a new instance.
Search WWH ::
Custom Search