Light weight mapper for models to DTO without using any constructor or the setters, easily map to new modesl with annotations
public class TestModel{
private String field1 = "10";
private String field2 = "20";
private String field3 = "30";
private String field4 = "40";
private Integer field5 = 50;
}
public class TestDTO {
@FieldMapper(field="field1")
private String testField1;
@FieldMapper(field="field2")
private String testField2;
@FieldMapper(field="field3")
private String testField3;
@FieldMapper(field="field4")
private Integer testField4;
private Integer field5;
}
Equivalent output will be
private String testField1 = "10";
private String testField2 = "20";
private String testField3 = "30";
private String testField4 = "40";
private Integer field5 = 50;
Mapping use the following helper
TestDTO dto = new in.saifali.mapper.Impl.Processor().map(TestDTO.class, model);
Please follow the test case for more information
You can use the same annotation and map dto to model and use the following Method reverse(Model.class, dto)
Model model = new in.saifali.mapper.Impl.Processor().reverse(Model.class, dto);
Gson Library Which one to convert The Model which is passed.
https://saifali40.github.io/mapper/
See the LICENSE file for license rights and limitations (Apache).