com.kenshoo.pl.entity.internal.LazyDelegatingMultiSupplier 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;
import com.kenshoo.pl.entity.ChangeOperation;
import com.kenshoo.pl.entity.CurrentEntityState;
import com.kenshoo.pl.entity.EntityField;
import com.kenshoo.pl.entity.EntityType;
import com.kenshoo.pl.entity.FieldsValueMap;
import com.kenshoo.pl.entity.spi.MultiFieldValueSupplier;
import com.kenshoo.pl.entity.spi.ValidationException;
import java.util.stream.Stream;
/**
* Created by yuvalr on 2/15/16.
*/
public class LazyDelegatingMultiSupplier> implements MultiFieldValueSupplier {
private final MultiFieldValueSupplier multiSupplier;
private FieldsValueMap suppliedMap;
public LazyDelegatingMultiSupplier(MultiFieldValueSupplier multiSupplier) {
this.multiSupplier = multiSupplier;
}
@Override
public FieldsValueMap supply(CurrentEntityState currentState) throws ValidationException {
if (suppliedMap == null) {
suppliedMap = multiSupplier.supply(currentState);
}
return suppliedMap;
}
@Override
public Stream> fetchFields(ChangeOperation changeOperation) {
return multiSupplier.fetchFields(changeOperation);
}
}