com.kenshoo.pl.entity.spi.RequiredFieldValidator 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.spi;
import com.kenshoo.pl.entity.CurrentEntityState;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import java.util.function.Predicate;
import java.util.stream.Stream;
/**
* A validator that force given a value in create command
*
* @param entity type
* @param required field type
*/
public interface RequiredFieldValidator, T> extends ChangeValidator {
/**
* @return the field that have to be
*/
EntityField requiredField();
/**
* @return the error code to return if the field is missing
*/
String getErrorCode();
/**
* @return Predicate when should validate field.
*/
default Predicate requireWhen() {
return e -> true;
}
/**
* @return a list of fields to fetch.
*/
default Stream> fetchFields() {
return Stream.of();
}
}