Java Reference
In-Depth Information
topics->symmetricDifference(topics.subtopics->
asSet())"/>
</eAnnotations>
</eStructuralFeatures>
Before regeneration, we need to make some changes in the genmodel. To
allow the OCL plug-in to be added to our generated manifest dependencies, we
need to add OCL_ECORE=org.eclipse.ocl.ecore to the Model Plug-in
Variables property of the genmodel root. Also, we need to set the Dynamic
Templates property to true and enter the templates path (such as /org.
eclipse.dsl.mindmap/templates/domain ) to the Template Directory
property. After we generate, we can see the following implementation in our
MapImpl class.
private static OCLExpression<EClassifier> rootTopicsDeriveOCL;
private static final String OCL_ANNOTATION_SOURCE =
"http://www.eclipse.org/2007/OCL";
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Topic> getRootTopics() {
EStructuralFeature eFeature =
MindmapPackage.Literals.MAP__ROOT_TOPICS;
if (rootTopicsDeriveOCL == null ) {
Helper helper = OCL_ENV.createOCLHelper();
helper.setAttributeContext(MindmapPackage.Literals.MAP, eFeature);
EAnnotation ocl = eFeature.getEAnnotation(OCL_ANNOTATION_SOURCE);
String derive = (String) ocl.getDetails().get("derive");
try {
rootTopicsDeriveOCL = helper.createQuery(derive);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query =
OCL_ENV.createQuery(rootTopicsDeriveOCL);
@SuppressWarnings("unchecked")
Collection<Topic> result = (Collection<Topic>) query.evaluate( this );
return new EcoreEList.UnmodifiableEList<Topic>( this , eFeature,
result.size(), result.toArray());
}
Search WWH ::




Custom Search