How could I define list variables in my ecore model?

120 views Asked by At

I have a class named File and another named Folder in GMF (Graphical Modeling Framework). In class definition, Folder has a method that returns List<File>, so how could I define in my ecore model?

1

There are 1 answers

1
aboyko On

You need to create a containment reference on Folder class. The reference will be 1-to-many and type of reference should be File

Suppose EClasses Folder and File are already created. Right-click on Folder EClass "New Child" -> "EReference" Select the EReference and open properties view for it Now while in EReference is selected perform the following in the properties view:

  1. Containment -> switch to true
  2. EType -> select File
  3. Name -> type "files"
  4. Upper Bound -> type -1 (means infinity)

This is it. The generated Folder class would have getter and setter for files feature.