Collection iteration

When retrieving information from a model, very often there is a need to access data stored in collections, and then iterate over these collections. MQL's dotted notation performs these tasks for you.

For example, in Java we would need to iterate over all classes, then iterate over all of their features, and then collect the feature names.

/*--------------- JAVA code ---------------*/
// Getting all the feature names of all the classes in the current model
com.sodius.mdw.core.model.Model uml = ...; 
java.util.List featureNames = new java.util.ArrayList();

// Iterates on all classes in the current model
for (java.util.Iterator classes = uml.getInstances("Class").iterator(); i.hasNext(); ) {
    Class myClass = (Class); 
    // Iterates on features of each class
    for (Iterator i = myClass.getFeature().iterator(); i.hasNext(); ) {
        Feature feature = (Feature);

In MQL this becomes a simple line.

/*--------------- MQL code ---------------*/
// Returns a list containing the name of each feature of each class
var featureNames = uml.getInstances("Class")