fi.jubic.easymapper.jooq.PlainJooqFieldAccessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easymapper-jooq Show documentation
Show all versions of easymapper-jooq Show documentation
Map JOOQ records to value objects.
package fi.jubic.easymapper.jooq;
import fi.jubic.easymapper.MappingException;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableField;
public class PlainJooqFieldAccessor implements JooqFieldAccessor {
private final TableField field;
public PlainJooqFieldAccessor(TableField field) {
this.field = field;
}
@Override
public R write(R output, F value) throws MappingException {
output.set(field, value);
return output;
}
@Override
public F extract(R input) throws MappingException {
return input.get(field);
}
@Override
public JooqFieldAccessor alias(Table tableAlias) {
return new PlainJooqFieldAccessor<>(
(TableField) tableAlias.field(field.getName(), field.getDataType())
);
}
}