package com.github.sergejsamsonow.codegenerator.pojo.renderer;

import com.github.sergejsamsonow.codegenerator.api.CodeFormat;
import com.github.sergejsamsonow.codegenerator.api.MethodCodeWriter;
import com.github.sergejsamsonow.codegenerator.pojo.model.PojoBean;
import com.github.sergejsamsonow.codegenerator.pojo.model.PojoProperty;

public class Setter extends AbstractPropertyRenderer<PojoProperty, PojoBean> {

    public Setter(CodeFormat format) {
        super(format);
    }

    @Override
    protected void writePropertyCode(PojoProperty property) {
        String type = property.getDeclarationType();
        String field = property.getFieldName();
        String setter = property.getSetterName();
        MethodCodeWriter writer = getMethodCodeWriter();
        writer.start("public void %s(%s %s) {", setter, type, field);
        writer.code("this.%s = %s;", field, field);
        writer.end();
    }
}

package com.github.sergejsamsonow.codegenerator.pojo.renderer;

import com.github.sergejsamsonow.codegenerator.api.CodeFormat;
import com.github.sergejsamsonow.codegenerator.api.MethodCodeWriter;
import com.github.sergejsamsonow.codegenerator.pojo.model.PojoBean;
import com.github.sergejsamsonow.codegenerator.pojo.model.PojoProperty;

public class Setter extends AbstractPropertyRenderer<PojoProperty, PojoBean> {

    public Setter(CodeFormat format) {
        super(format);
    }

    @Override
    protected void writePropertyCode(PojoProperty property) {
        String type = property.getDeclarationType();
        String field = property.getFieldName();
        String name = property.getSetterName();
        MethodCodeWriter method = getMethodCodeWriter();
        method.start("public void %s(%s %s) {", name, type, field);
        method.code("this.%s = %s;", field, field);
        method.end();
    }
}

Implement example producer Small refactoring
3: Implement example producer 
Small refactoring

Task-Url:
http://github.com/sergej-samsonow/code-generator/issues/issue/3