Main Page/Resources/MTBenchmark/Class2Java

From Atenea

Jump to: navigation, search

Contents

Class2Java

Metamodels

Input metamodel

Download Class.ecore or show Class.ecore tree view

Image:ClassMM.png

Output metamodel

Download JDTAST.ecore or show JDTAST.ecore tree view

Transformation

As an example, in the following we show the ATL transformation for this case study. The code can be downloaded from here.

module Class2Java;
create OUT : MM1 from IN : MM;
rule Packages {
   from
      p : MM!Package
   to 
      ipf : MM1!IPackageFragment (
         compilationUnits <- p.classes,
         elementName <- p.name,
         isDefaultPackage <- false
      )
}
rule Classes {
   from
      c : MM!Class
   to 
      icu : MM1!ICompilationUnit (
         elementName <- c.name + '.java',
         types <- Sequence{t}
      ),
      t : MM1!IType(
         elementName <-  c.name,
         fields <- c.att,
         methods <- c.methods
      )
}
rule Attributes {
   from
      a : MM!Attribute
   to 
      fd : MM1!IField (
         elementName <- a.name,
         typeSignature <- a.type.name
      )
}
rule Methods {
   from
      m : MM!Method
   to 
      md : MM1!IMethod(
         elementName <- m.name,
         parameters <- m.params
      )
}
rule Parameters {
   from
      p : MM!Parameter
   to 
      svd : MM1!Parameter(
         name <- p.name,
         type <- p.type.name
      )
}

Input models

The input models are the same that were presented [here] for the Identity case study.

Personal tools