DataDecorator extends AbstractTransformer<ASTCDClass> { @Override public ASTCDClass decorate(final ASTCDClass originalClass, ASTCDClass changedClass) { this.clazzName = originalClass.deepClone().getName(); changedClass.addCDConstructor(createDefaultConstructor(originalClass)); if (originalClass.isPresentSuperclass()) { changedClass.setSuperclass(originalClass.getSuperclass()); } changedClass.addAllInterface(originalClass.getInterfaceList()); changedClass.addAllCDMethods(originalClass.getCDMethodList()); List<ASTCDAttribute> ownAttributes = originalClass.deepClone().getCDAttributeList() .stream() .filter(a -> !service.isInheritedAttribute(a)) .collect(Collectors.toList()); changedClass.addAllCDMethods(getAllDataMethods(originalClass, originalClass.getCDAttributeList())); changedClass.addCDMethod(createDeepCloneWithParam(originalClass, ownAttributes)); changedClass.setCDAttributeList(ownAttributes); changedClass.getCDAttributeList().forEach(this::addAttributeDefaultValues); changedClass.addAllCDMethods(service.getMethodListWithoutDuplicates(originalClass.getCDMethodList(), createGetter(ownAttributes))); changedClass.addAllCDMethods(service.getMethodListWithoutDuplicates(originalClass.getCDMethodList(), createSetter(ownAttributes))); return changedClass; } DataDecorator(final GlobalExtensionManagement glex, final MethodDecorator methodDecorator,
                       final AbstractService service, final DataDecoratorUtil dataDecoratorUtil); @Override ASTCDClass decorate(final ASTCDClass originalClass, ASTCDClass changedClass);  }
@Test public void testGeneratedAutomatonCode() { ASTCDCompilationUnit cd = this.parse("de", "monticore", "codegen", "ast", "Automaton"); ASTCDClass clazz = getClassBy("ASTAutomaton", cd); MethodDecorator methodDecorator = new MethodDecorator(glex, new ASTService(cd)); DataDecorator dataDecorator = new DataDecorator(glex, methodDecorator, new ASTService(cd), new DataDecoratorUtil()); ASTCDClass changedClass = CD4AnalysisMill.cDClassBuilder().setName(clazz.getName()) .setModifier(clazz.getModifier()) .build(); clazz = dataDecorator.decorate(clazz, changedClass); glex.setGlobalValue("astHelper", DecorationHelper.getInstance()); GeneratorSetup generatorSetup = new GeneratorSetup(); generatorSetup.setGlex(glex); GeneratorEngine generatorEngine = new GeneratorEngine(generatorSetup); StringBuilder sb = generatorEngine.generate(CoreTemplates.CLASS, clazz, clazz); ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); }