@Override public boolean filter(Element e) { return e instanceof Constraint && ((Constraint) e).getContext().equals(element); } });
public static String getAsOcl(Constraint constraint) { Operation oper = (Operation) constraint.getContext(); StringBuilder sb = new StringBuilder(); sb.append("package "); sb.append(Namer.nameIncludingModel(oper.getNearestPackage()).replace(".", "::")); sb.append("\ncontext "); sb.append(UmlgOperationOperations.asOclSignature(oper)); sb.append("\n"); sb.append("body: "); sb.append(constraint.getSpecification().stringValue()); sb.append("\n"); sb.append("endpackage"); return sb.toString(); }
public String getConstraintOclAsString() { Namespace context = this.constraint.getContext(); ValueSpecification valueSpecification = this.constraint.getSpecification(); StringBuilder sb = new StringBuilder(); sb.append("package "); sb.append(Namer.nameIncludingModel(context.getNearestPackage()).replace(".", "::")); sb.append("\n context "); sb.append(context.getName()); sb.append(" inv:"); sb.append("\n "); sb.append(valueSpecification.stringValue()); sb.append("\n"); sb.append("endpackage"); return sb.toString(); }
@Override public Object caseConstraint(Constraint constraint) { Namespace constraintContext = constraint.getContext(); if (constraintContext != null) { EModelElement eModelElement = (EModelElement) doSwitch(constraintContext); if (eModelElement != null) { if (eModelElement instanceof EClassifier && options != null && !OPTION__IGNORE.equals(options .get(OPTION__INVARIANT_CONSTRAINTS))) { eModelElement = processInvariantConstraint( (EClassifier) eModelElement, constraint, options, diagnostics, context); } ValueSpecification specification = constraint .getSpecification(); if (specification != null && !(eModelElement instanceof EOperation && options != null && OPTION__PROCESS .equals(options.get(OPERATION_BODY)))) { addDocumentation(eModelElement, specification .stringValue()); } return eModelElement; } } return super.caseConstraint(constraint); }