Java Reference
In-Depth Information
mapping
dnc::Archetype::toSerializableClass() : java::JavaClass
inherits
dnc::Archetype::toClass {
implementsInterfaces += 'java.io.Serializable'.
map
toClass();
}
mapping
dnc::Archetype::toStateful() : java::JavaClass
inherits
dnc::Archetype::toSerializableClass {
eAnnotations += toAnnotation('description',
self
.description,
null
);
eAnnotations += toAnnotation('annotation', '@Stateful',
null
);
classImport += 'javax.ejb.Stateful'.
map
toClass();
}
In this example,
toStateful()
inherits from
toSerializableClass()
,
which, in turn, inherits from
toClass()
.
merges
Sometimes a mapping operation produces multiple outputs or results in an object
that is the logical combination of other defined mappings. By allowing for the
merging of mapping operations, the language of the transformation more closely
approximates a natural language. In terms of execution semantics, the merged
mappings are invoked following the end of the merging mapping. All mappings,
including
out
, are passed to the merged mapping.
We can modify our previous
inherits
example to include
merges
for the
serializable aspect of the stateful class. In this case, a stateful bean is a class that
also is serializable.
mapping
dnc::Archetype::toClass() : java::JavaClass {
name :=
self
.name;
fields +=
self
.getAttributes().
map
toField(
result
);
methods +=
self
.getOperations().
map
toMethod();
}
mapping
dnc::Archetype::toSerializableClass() : java::JavaClass {
implementsInterfaces += 'java.io.Serializable'.
map
toClass();
}
mapping
dnc::Archetype::toStateful() : java::JavaClass
inherits
dnc::Archetype::toClass
merges
dnc::Archetype::toSerializableClass {
eAnnotations += toAnnotation('description',
self
.description,
null
);
eAnnotations += toAnnotation('annotation', '@Stateful',
null
);
classImport += 'javax.ejb.Stateful'.
map
toClass();
}
Search WWH ::
Custom Search