Java Reference
In-Depth Information
If you examine the output of this mapping, you'll find that isPrimaryKey
and type are both set correctly during the init , while the name of the returned
instance is simply updated in the mapping body without instantiating a new
TableColumn . Similarly, access to the result is available in the end{} block, as
shown next. Here again, update semantics are in effect in both the body and end
blocks because there is an implicit instantiation of the return object.
mapping UML::Property::primitiveAttribute2column( in targetType:
UML::DataType) : RDB::TableColumn
when { self .isPrimitive() }
{
name := self.name;
end {
result .isPrimaryKey := self.isPrimaryKey();
result .type := object RDB::datatypes::PrimitiveDataType {
name := umlPrimitive2rdbPrimitive(self.type.name);
};
}
}
Another reason to explicitly create an object is for assignment to return
parameters where more than one is defined for a mapping. Consider this example:
mapping X::toYZ() : y:Y, z:Z {
object y:Y {
};
object z:Z {
};
}
13.5.5 Mapping Invocation
When invoking a mapping, use either the map or xmap keyword, where xmap
represents invocation with strict semantics. The map keyword is used after a dot
(.) or alternatively after an arrow ( -> ) when using the collect shorthand. When
invocated, as long as the mapping can be resolved using the actual context and
the guard conditions are satisfied (if present), the trace is consulted to look for
target instances produced from the given source object. If present, the relation
holds and the previous result is returned. Otherwise, the mapping body is
executed.
In this first example, the input is being mapped using nonstrict semantics to
a requirements Model using the more popular form of invocation.
Search WWH ::




Custom Search