All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kenshoo.pl.entity.spi.FieldComplexValidator Maven / Gradle / Ivy

Go to download

A Java persistence layer based on JOOQ for high performance and business flow support.

There is a newer version: 0.1.121-jooq-3.16.3
Show newest version
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();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy