@Override public Constraint getBodyCondition() { return this.operation.getBodyCondition(); }
@Override public void visitBefore(Operation oper) { Element operOwner = oper.getOwner(); if (oper.getBodyCondition() != null && !oper.isQuery()) { throw new IllegalStateException(String.format("Operation %s on %s has a bodyCondition but is not a query.", new Object[] { oper.getName(), ((NamedElement) operOwner).getName() })); } OJAnnotatedClass ojClass; if (operOwner instanceof Interface) { ojClass = findOJClass((Interface) operOwner); addOperSignature(ojClass, oper); } else if ((operOwner instanceof org.eclipse.uml2.uml.Class) || (operOwner instanceof Enumeration)) { ojClass = findOJClass((org.eclipse.uml2.uml.Classifier) operOwner); OJAnnotatedOperation ojOper = addOperSignature(ojClass, oper); if (oper.isQuery()) { addQueryBody(ojClass, ojOper, oper); } } else { throw new IllegalStateException("Operations are only supported on Interfaces and Classes, not on " + operOwner.toString()); } }
Constraint bodyCondition = operation.getBodyCondition();
Constraint bodyCondition = operation.getBodyCondition();
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * A bodyCondition can only be specified for a query operation. * bodyCondition->notEmpty() implies isQuery * @param operation The receiving '<em><b>Operation</b></em>' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * <!-- end-model-doc --> * @generated NOT */ public static boolean validateOnlyBodyForQuery(Operation operation, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; if (operation.getBodyCondition() != null && !operation.isQuery()) { result = false; if (diagnostics != null) { diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.OPERATION__ONLY_BODY_FOR_QUERY, UMLPlugin.INSTANCE.getString( "_UI_Operation_OnlyBodyForQuery_diagnostic", //$NON-NLS-1$ getMessageSubstitutions(context, operation)), new Object[]{operation})); } } return result; }