com.kenshoo.pl.entity.EntityFieldDbAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of persistence-layer Show documentation
Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
package com.kenshoo.pl.entity;
import com.kenshoo.jooq.DataTable;
import org.jooq.Identity;
import org.jooq.Record;
import org.jooq.TableField;
import java.util.Iterator;
import java.util.Optional;
import java.util.stream.Stream;
/**
* Handles the transformation of a value for the entity field this adapter is attached to,
* to the database and vice versa.
*
* @param type of the entity field
*/
public interface EntityFieldDbAdapter {
/**
* @return the table this entity fields maps to
*/
DataTable getTable();
/**
* @return the table fields this entity field maps to
*/
Stream> getTableFields();
/**
* @return the first table field that this entity field maps to
* @throws IllegalStateException if there are no fields
*/
default TableField getFirstTableField() {
return getTableFields().findFirst()
.orElseThrow(() -> new IllegalStateException("There must be at least one field but none found"));
}
/**
* @param value value of entity field to translate
* @return the values for the fields returned by {@link #getTableFields()}, in the same order
*/
Stream