// Copied from org.eclipse.ocl.examples.test.xtext.PivotDocumentationExamples.java // define a post-condition specifying the value of EModelElement::getEAnnotation(EString). // This operation environment includes variables representing the operation // parameters (in this case, only "source : String") and the operation result EOperation contextEOperation = NameUtil.getENamedElement( EcorePackage.Literals.EMODEL_ELEMENT.getEOperations(), "getEAnnotation"); ExpressionInOCL body = ocl.createPostcondition(contextEOperation, "result = self.eAnnotations->any(ann | ann.source = source)"); // define a derivation constraint for the EReference::eReferenceType property EReference contextEReference = EcorePackage.Literals.EREFERENCE__EREFERENCE_TYPE; ExpressionInOCL derive = ocl.createQuery(contextEReference, "self.eType->any(true).oclAsType(EClass)");