How to create Java code from Ecore metamodel without jff dependencies?

Is it possible to generate Java code from the Ecore metamodel without EMF dependencies? Create "clean code" as if it were a generation from a UML model.

+3
source share
2 answers

A simple way is to set the GenModel option "Suppress EMF types" in the "Default parameters for the model" section of the top level node ... There is a set of holes for the corresponding parameters. See the EMF Book (2nd Edition) for more information.

JET Java ECore. "" EMF: , Java" .

+2

EMF. #eSet, #eGet .. . eInvoke "Operation Reflection" = false. , " Factory" = false. , genmodel - . EMF Modeling Framework, 12.3.1.

, " EMF" EMF EOperation EReference , ivar , getter ( null). - Class.javajet, . , EMF, . using-dynamic-templates-in-emf.

ivar Feature#getImportedType, Feature#getImportedInternalType:

protected <%=genFeature.getImportedType(genClass)%> <%=genFeature.getSafeName()%>;

, , isListType:

<%} else if (genFeature.isListType() || genFeature.isReferenceType()) {%>
  <%if (genClass.isField(genFeature)) {%>
/**
 * The cached value of the '{@link #<%=genFeature.getGetAccessor()%>() <em><%=genFeature.getFormattedName()%></em>}' <%=genFeature.getFeatureKind()%>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->

EMF EList impl ArrayList:

<%=genFeature.getSafeName()%> = new <%=genModel.getImportedName("java.util.ArrayList")%><<%=genFeature.getListItemTy‌​pe()%>>();

instead of:
<%=genFeature.getSafeName()%> = new <%=genClass.getListConstructor(genFeature)%>;
0

All Articles