4141 */
4242public class JavaCodeEcorification {
4343 private static final Logger logger = LogManager .getLogger (JavaCodeEcorification .class .getName ());
44- private final FieldEncapsulator fieldEncapsulator ;
4544 private final GenModelGenerator genModelGenerator ;
4645 private final ImportOrganizer importOrganizer ;
47- private final InheritanceManipulator inheritanceManipulator ;
4846 private final EcoreMetamodelExtraction metamodelGenerator ;
4947 private final EcorificationProperties properties ;
5048 private final WrapperGenerator wrapperGenerator ;
@@ -57,14 +55,13 @@ public JavaCodeEcorification() {
5755 metamodelGenerator = new EcorificationExtraction (properties );
5856 genModelGenerator = new GenModelGenerator (properties );
5957 wrapperGenerator = new WrapperGenerator (properties );
60- fieldEncapsulator = new FieldEncapsulator (properties );
6158 importOrganizer = new ImportOrganizer (properties );
62- inheritanceManipulator = new InheritanceManipulator (properties );
6359 }
6460
6561 /**
66- * Starts the ecorification for a specific Java project. Initializes the different steps of the Ecorification
67- * pipeline: The extraction of an Ecore metamodel, the Ecore model code generation, the wrapper generation and the
62+ * Starts the ecorification for a specific Java project. Initializes the
63+ * different steps of the Ecorification pipeline: The extraction of an Ecore
64+ * metamodel, the Ecore model code generation, the wrapper generation and the
6865 * origin code adaption.
6966 * @param originalProject is the specific Java project as {@link IProject}.
7067 */
@@ -81,15 +78,16 @@ public void start(IProject originalProject) {
8178 }
8279
8380 /**
84- * 5. Encapsulates all fields of the origin code. Removes public, non-static fields and their access methods,
85- * organizes all imports, manipulates the inheritance relations to extend the wrappers, creates default constructors
81+ * 5. Encapsulates all fields of the origin code. Removes public, non-static
82+ * fields and their access methods, organizes all imports, manipulates the
83+ * inheritance relations to extend the wrappers, creates default constructors
8684 * where they are missing.
8785 */
8886 private void adaptOriginCode (GeneratedEcoreMetamodel metamodel , IProject project ) {
89- fieldEncapsulator .manipulate (project );
87+ new FieldEncapsulator ( metamodel . getIntermediateModel (), properties ) .manipulate (project );
9088 new MemberRemover (metamodel , properties ).manipulate (project );
9189 importOrganizer .manipulate (project );
92- inheritanceManipulator .manipulate (project );
90+ new InheritanceManipulator ( metamodel . getIntermediateModel (), properties ) .manipulate (project );
9391 }
9492
9593 /**
@@ -98,15 +96,15 @@ private void adaptOriginCode(GeneratedEcoreMetamodel metamodel, IProject project
9896 private void buildFactories (GeneratedEcoreMetamodel metamodel , IProject project ) {
9997 new FactoryRenamer (metamodel , properties ).manipulate (project );
10098 new FactoryImplementationRenamer (metamodel , properties ).manipulate (project );
101- new DefaultConstructorGenerator (properties ).manipulate (project );
99+ new DefaultConstructorGenerator (properties , metamodel . getIntermediateModel () ).manipulate (project );
102100 new EcoreFactoryGenerator (properties ).buildFactories (metamodel , project );
103101 new PackageImplFactoryCorrector (metamodel , properties ).manipulate (project );
104102 new ClassExposer (properties ).manipulate (project );
105103 }
106104
107105 /**
108- * 1. Extracts a Ecore metamodel in form of an {@link GeneratedEcoreMetamodel} from the original {@link IProject}.
109- * Generates a {@link GenModel}.
106+ * 1. Extracts a Ecore metamodel in form of an {@link GeneratedEcoreMetamodel}
107+ * from the original {@link IProject}. Generates a {@link GenModel}.
110108 */
111109 private GeneratedEcoreMetamodel extractMetamodel (IProject originalProject ) {
112110 GeneratedEcoreMetamodel metamodel = metamodelGenerator .extract (originalProject );
@@ -116,7 +114,8 @@ private GeneratedEcoreMetamodel extractMetamodel(IProject originalProject) {
116114 }
117115
118116 /**
119- * 6. Finishes the ecorification: Organizes all imports, rebuilds the project and notifies the user.
117+ * 6. Finishes the ecorification: Organizes all imports, rebuilds the project
118+ * and notifies the user.
120119 */
121120 private void finish (IProject project ) {
122121 importOrganizer .manipulate (project );
@@ -125,7 +124,8 @@ private void finish(IProject project) {
125124 }
126125
127126 /**
128- * 3. Generates the wrappers, which are the classes that unify the origin code with the Ecore code.
127+ * 3. Generates the wrappers, which are the classes that unify the origin code
128+ * with the Ecore code.
129129 */
130130 private void generateWrappers (GeneratedEcoreMetamodel metamodel , IProject project ) {
131131 XtendLibraryHelper .addXtendLibs (project , properties );
@@ -149,8 +149,9 @@ private IProject getProject(SavingInformation information) {
149149 }
150150
151151 /**
152- * 4. Manipulates the imports of the Ecore code. Every Ecore interface and every correlating implementation class
153- * will use the origin code types instead of ecore code types.
152+ * 4. Manipulates the imports of the Ecore code. Every Ecore interface and every
153+ * correlating implementation class will use the origin code types instead of
154+ * ecore code types.
154155 */
155156 private void manipulateEcoreImports (GeneratedEcoreMetamodel metamodel , IProject project ) {
156157 new EcoreImportManipulator (metamodel , properties ).manipulate (project ); // 4. adapt imports
0 commit comments