/** Visit class 'TupleLiteralExp' */ public Object visit(TupleLiteralExp host, Object data) { String result = "Tuple {"; // --- add all properties --- Iterator i = host.getTuplePart().iterator(); while (i.hasNext()) { VariableDeclaration var = (VariableDeclaration) i.next(); result += (String) var.accept(this, data); if (i.hasNext()) result += ", "; } result += "}"; return result; }
/** Generate code for 'collect' */ protected Object collect( IteratorExp host, VariableDeclaration var1, VariableDeclaration var2, OclExpression body, Map data) { String result = ""; result += host.getSource().accept(this, data); result += "->collect( " + var1.getName() + "|\n"; result += " " + body.accept(this, data); result += ")"; return result; // Object result = collectNested(host, var1, var2, body, data); // Classifier hostType = host.getType(); // --- Flatten --- // if (hostType instanceof BagType) { // result = ((OclBag) result).flatten(); // } else if (hostType instanceof OrderedSetType) { // result = ((OclOrderedSet) result).flatten(); // } else if (hostType instanceof SetType) { // result = ((OclSet) result).flatten(); // } else if (hostType instanceof SequenceType) { // result = ((OclSequence) result).flatten(); // } // return result; }
/** Generate code for 'sortedBy' */ protected Object sortedBy( IteratorExp host, VariableDeclaration var1, VariableDeclaration var2, OclExpression body, Map data) { String result = host.getSource().accept(this, data) + "\n"; result += "->sortedBy( " + var1.getName() + "|\n"; result += " " + body.accept(this, data); result += ")"; return result; }
/** Visit class 'VariableDeclaration' */ public Object visit(VariableDeclaration host, Object data) { String x = host.getName() + ":" + host.getType().getFullName("::"); if (host.getInitExpression() != null) x += " = " + host.getInitExpression().accept(this, data); return x; }