com.kenshoo.pl.simulation.internal.ActualResultFetcher 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.simulation.internal;
import com.kenshoo.pl.entity.Entity;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import com.kenshoo.pl.entity.Identifier;
import com.kenshoo.pl.entity.internal.EntitiesFetcher;
import com.kenshoo.pl.simulation.ActualMutatorError;
import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import static org.jooq.lambda.Seq.seq;
public class ActualResultFetcher> {
private final EntitiesFetcher fetcher;
private final Collection> inspectedFields;
public ActualResultFetcher(EntitiesFetcher fetcher, Collection> inspectedFields) {
this.fetcher = fetcher;
this.inspectedFields = inspectedFields;
}
public Iterable fetch(
Collection extends Identifier> allIds,
Map, ActualMutatorError> errors,
Function, Entity> originalStates) {
final var finalStates = fetcher.fetchEntitiesByIds(allIds, inspectedFields);
return seq(allIds).map(id -> {
final var originalState = originalStates.apply(id);
final var finalState = finalStates.get(id);
if (errors.containsKey(id)) {
return new ActualError(errors.get(id).getDescription());
}
if (originalState == null) {
return new ActualError("Could not find original state");
}
if (finalState == null) {
return new ActualError("Could not find final state");
}
return new ActualSuccess(originalState, finalState);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy