Information Technology Reference
In-Depth Information
and the relationalDatabaseMetamodel . In line 4, a
transformationruleappears.Thistransformationrulereceives
one Class element as parameter, myClass , and returns a
Table element. As soon as this transformation rule starts
its execution, a Table element is created. In line 5, the
name property of myClass is assigned to the name property
of the created Table element. In line 9, the transformation
rule createColumn(Attribute myAtt, Table myTable)
is called for each attribute of myClass . This transformation
rule receives an Attribute element and a Table element,
creates a Column element from the received attribute, adds it
to the collection of attributes of the received Table element,
and returns the created Column element.
1
2
3
4
5
6
7
8
9
10
11
12
import classMetamodel;
import relationalDatabaseMetamodel;
create Table class2ER (Class myClass ):
this.setName(myClass.name)−>
myClass. attributes.createColumn(this)−>
this;
create Column createColumn(Attribute myAtt, Table myTable):
this.setName(myAtt.name)−>
myTable.add( this)
this;
Listing 3.10. Example of an Xtend model transformation
In Xtend, a function is evaluated only once for each unique
combination of parameters. Thus, one can call the same
function with the same number of arguments multiple times,
and it will only be evaluated the first time. This is an essential
feature when working with graph transformations; especially,
if they contain circular references. The Xtend language also
provides the possibility to define libraries of independent
operations and non-invasive metamodel extensions based on
either Java methods or oAW expressions. Those libraries can
be referenced from all other textual languages that are based
on the expressions framework such as Xpand.
 
Search WWH ::




Custom Search