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

com.kenshoo.pl.entity.spi.PostFetchCommandEnricher 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.*;

import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;

/**
 * As opposed to {@link FieldValueSupplier} which is implemented by the end-user flow, this interface is implemented
 * by operations that are considered inherent part of the persistence layer. For example, if every newly generated
 * entity should get a unique affcode, this logic is implemented with an enricher (by implementing this interface).
 * The enrichers are called after the current state is fetched and user-specified suppliers are resolved but before
 * the changes are validated.
 *
 * @param 
 */
public interface PostFetchCommandEnricher> extends CurrentStateConsumer {

    /**
     * "Enriches" the commands with system-imposed changes.
     *  @param commands      commands to enrich
     * @param changeOperation operation
     * @param changeContext the context of the operation
     */
    void enrich(Collection> commands, ChangeOperation changeOperation, ChangeContext changeContext);

    /**
     * return stream of enriched fields according to input commands.
     *
     * @return the fields should be enriched
     */
    default Stream> fieldsToEnrich() {
        return Stream.empty();
    }

    /**
     * @param entityChanges to enrich
     *
     * @return indicator that enricher should be run
     */
    default boolean shouldRun(Collection> entityChanges) {
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy