package com.artemis.generator.strategy.supermapper;

import com.artemis.BaseSystem;
import com.artemis.generator.common.BuilderModelStrategy;
import com.artemis.generator.model.artemis.ArtemisModel;
import com.artemis.generator.model.type.AccessLevel;
import com.artemis.generator.model.type.MethodDescriptor;
import com.artemis.generator.model.type.TypeModel;
import com.artemis.generator.util.MethodBuilder;

/**
 * Generate basic scaffold for SuperMapper class.
 *
 * @author Daan van Yperen
 */
public class SuperMapperStrategy implements BuilderModelStrategy {

    @Override
    public void apply(ArtemisModel artemisModel, TypeModel model) {
        model.name = "SuperMapper";
        model.packageName = "com.artemis";
        model.superclass = BaseSystem.class;
        model.add(createInitializationMethod());
    }

    private MethodDescriptor createInitializationMethod() {
        return new MethodBuilder(void.class, "processSystem")
                .accessLevel(AccessLevel.PUBLIC)
                .statement("E._processingMapper=this")
                .build();
    }

}

@@ -815,16 +815,61 @@
 hod());%0A
+        model.add(createProcessingMethod());%0A
     %7D%0A%0A 
@@ -898,38 +898,34 @@
 iptor create
-Initialization
+Processing
 Method() %7B%0A 
@@ -1122,10 +1122,269 @@
 %0A    %7D%0A%0A
+    private MethodDescriptor createInitializationMethod() %7B%0A        return new MethodBuilder(void.class, %22initialize%22)%0A                .accessLevel(AccessLevel.PROTECTED)%0A                .statement(%22E._processingMapper=this%22)%0A                .build();%0A    %7D%0A%0A
 %7D%0A

Initialize SuperMapper as soon as possible to allow initialization() usage of E.