SimpleFlatMapper
SimpleFlatMapper copied to clipboard
Add JooqBiConverter to help JooqRecord <-> Java Object custom conversion
JooqBiConverter should be shared between RecordMapper and RecordUnmapper. It should be helpful to make code more lean and readable.
Usage:
List<JooqBiConverter> converters = new ArrayList<>();
converters.add(new JooqBiConverter<String, JSONObjectTest494.File>() {
@Override
public boolean match(Type modelType) {
return TypeHelper.areEquals(modelType, JSONObjectTest494.File.class);
}
@Override
public JSONObjectTest494.File get(String name, Context context) throws Exception {
return new JSONObjectTest494.File(0L, name, null);
}
@Override
public String convert(JSONObjectTest494.File file, Context context) throws Exception {
return file.name;
}
});
JooqMapperFactory mapperFactory = JooqMapperFactory.newInstance()
.addBiConverters(converters);
Hidden rule: JooqMapperFactory.addBiConverters() could only be called once. Later converters will override previous added converters. RecordUnmapperBuilder need to be changed to fix this.
might seat on that one for a bit, I think that concept can also be useful in other integrations.