com.kenshoo.pl.entity.internal.audit.AuditRequiredFieldsCalculator 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.internal.audit;
import com.kenshoo.pl.entity.ChangeOperation;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import com.kenshoo.pl.entity.spi.CurrentStateConsumer;
import org.jooq.lambda.Seq;
import java.util.Collection;
import java.util.Set;
import java.util.stream.Stream;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toSet;
import static org.jooq.lambda.Seq.seq;
public class AuditRequiredFieldsCalculator> implements CurrentStateConsumer {
private final AuditedEntityType auditedEntityType;
public AuditRequiredFieldsCalculator(final AuditedEntityType auditedEntityType) {
this.auditedEntityType = requireNonNull(auditedEntityType, "auditedEntityType is required");
}
@Override
public Stream extends EntityField, ?>> requiredFields(final Collection extends EntityField> fieldsToChange,
final ChangeOperation changeOperation) {
final Set extends EntityField> onChangeFields = auditedEntityType.getUnderlyingOnChangeFields().collect(toSet());
final Seq extends EntityField> intersectedChangeFields =
seq(fieldsToChange).filter(onChangeFields::contains);
return Seq.>of(auditedEntityType.getIdField())
.append(auditedEntityType.getUnderlyingMandatoryFields())
.append(intersectedChangeFields);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy