Java Reference
In-Depth Information
mapping UML::Property::primitiveAttribute2column( in targetType:
UML::DataType) : RDB::TableColumn
when { self .isPrimitive() }
{
init {
var primitiveType : RDB::datatypes::PrimitiveDataType :=
object RDB::datatypes::PrimitiveDataType {
name := umlPrimitive2rdbPrimitive( self .type.name);
};
}
isPrimaryKey := self .isPrimaryKey();
name := self .name;
type := primitiveType;
}
As stated earlier, objects that are created are first checked for existence. If
they are null , a new object of the stated type is instantiated and initialized in
the order of the statements in the body. If the object already exists, its contents
are updated according to the statements in the body. This implies that update
semantics are used in object statements where an object has already been instan-
tiated. Consider this example:
mapping UML::Property::primitiveAttribute2column( in targetType:
UML::DataType) : RDB::TableColumn
when { self .isPrimitive() }
{
init {
result := object RDB::TableColumn {
isPrimaryKey := self.isPrimaryKey();
type := object RDB::datatypes::PrimitiveDataType {
name := umlPrimitive2rdbPrimitive(self.type.name);
};
};
}
name := self.name;
}
This example shows the use of the result keyword, in addition to the inlin-
ing of mapping operations. By default, the returned model instance of a mapping
is assigned to the result , which we're explicitly setting here in the init section.
We're then updating the result in the mapping body to set the name property.
Technically, the implicit instantiation section that exists between the init sec-
tion and the population section (or the mapping body, in this case) recognizes
the existence of the instantiated result and incorporates update semantics.
Search WWH ::




Custom Search