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

com.kenshoo.pl.entity.internal.CreationDateEnricher 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.internal;

import com.kenshoo.pl.entity.ChangeContext;
import com.kenshoo.pl.entity.ChangeEntityCommand;
import com.kenshoo.pl.entity.ChangeOperation;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import com.kenshoo.pl.entity.SupportedChangeOperation;
import com.kenshoo.pl.entity.spi.PostFetchCommandEnricher;

import java.time.Instant;
import java.util.Collection;
import java.util.stream.Stream;

/**
 * Created by yuvalr on 2/3/16.
 */
public class CreationDateEnricher> implements PostFetchCommandEnricher {

    private final EntityField creationDateField;

    public CreationDateEnricher(EntityField creationDateField) {
        this.creationDateField = creationDateField;
    }

    @Override
    public void enrich(Collection> changeEntityCommands, ChangeOperation changeOperation, ChangeContext changeContext) {
        Instant now = Instant.now();
        changeEntityCommands.forEach(command -> command.set(creationDateField, now));
    }

    @Override
    public Stream> fieldsToEnrich() {
        return Stream.of(creationDateField);
    }


    @Override
    public SupportedChangeOperation getSupportedChangeOperation() {
        return SupportedChangeOperation.CREATE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy