fi.jubic.easymapper.jooq.Jooq 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 org.jooq.Record;
import org.jooq.TableField;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.function.Function;
public final class Jooq {
public static JooqFieldAccessor jooqField(
TableField field
) {
return new PlainJooqFieldAccessor<>(field);
}
public static JooqFieldAccessor jooqField(
TableField field,
Function writeTransform,
Function extractTransform
) {
return new TransformingJooqFieldAccessor<>(
field,
writeTransform,
extractTransform
);
}
public static JooqFieldAccessor jooqTimestampField(
TableField field
) {
return jooqField(
field,
Timestamp::from,
Timestamp::toInstant
);
}
public static
JooqReferenceAccessor jooqReference(
TableField field,
Function idGetter
) {
return new JooqReferenceAccessor<>(idGetter, jooqField(field));
}
}