com.kenshoo.pl.entity.spi.FieldComplexValidator 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 com.kenshoo.pl.entity.ValidationError;
import java.util.stream.Stream;
/**
* A validator that checks one field and uses parent entity fields for the verification. For instance,
* a validator that checks that a bid doesn't exceed campaign budget, would implement this interface.
*
* @param entity type
* @param data type of the field being validated
*/
public interface FieldComplexValidator, T> extends ChangeValidator {
/**
* @return the field validated by this validator
*/
EntityField validatedField();
/**
* Called by the framework to validate the value. The implementation can query the entity
only for
* the fields it has declared in {@link #fetchFields()}.
*
* @param fieldValue new value of the field
* @param currentState existing entity
*
* @return a validation error if any, null
if none
*/
ValidationError validate(T fieldValue, CurrentEntityState currentState);
/**
* @return a list of fields to fetch. Can contain only parent entities fields.
*/
Stream> fetchFields();
}