A list of model elements is represented by the interface
MDWList,
which is an sub interface of java.util.List.
It provides facilities to invoke scripts on each model element of this list.
MDWList enables to :
String using concat(String scriptName)MDWList using collect(String scriptName)MDWObject elements of this list based on script results :
select(String scriptName, Object value)detect(String scriptName, Object value)reject(String scriptName, Object value)MDWObject elements of this list based on metatype using getInstances(String typeName)MDWObject elements of this list using sort(String scriptName)Let's take an MDWList containing UML classes Customer, Bank and Account
Concatenates the name of each Class:
myList.concat("name")
// output example: "CustomerBankAccount"
Concatenates the name of each Class, separated by a comma:
myList.concat("name", ", ")
// output example: "Customer, Bank, Account"
Creates an MDWList of each Feature of each Class:
myList.collect("feature")
// output example: [name, address, zipcode, number]
Concatenates the name each Feature of each Class, separated by a comma:
myList.collect("feature").concat("name", ", ")
// output example: "name, address, zipcode, number"
Gets the feature named "zipcode":
myList.collect("feature").detect("name", "zipcode")
// output: zipcode
Gets the non-abstract classes:
myList.select("isAbstract", Boolean.FALSE)
// output example: [Customer, Account]
Concatenates the name of each Class, separated by a comma and sorted by name:
myList.sort("name").concat("name", ", ")
// output example: "Account, Bank, Customer"