cdm.event.common.functions.EmptyTransferHistory Maven / Gradle / Ivy
package cdm.event.common.functions;
import cdm.event.common.TransferState;
import cdm.event.common.TransferState.TransferStateBuilder;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.ModelObjectValidator;
import com.rosetta.model.lib.functions.RosettaFunction;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.inject.Inject;
@ImplementedBy(EmptyTransferHistory.EmptyTransferHistoryDefault.class)
public abstract class EmptyTransferHistory implements RosettaFunction {
@Inject protected ModelObjectValidator objectValidator;
/**
* @return emptyTransferHistory
*/
public List extends TransferState> evaluate() {
List emptyTransferHistoryBuilder = doEvaluate();
final List extends TransferState> emptyTransferHistory;
if (emptyTransferHistoryBuilder == null) {
emptyTransferHistory = null;
} else {
emptyTransferHistory = emptyTransferHistoryBuilder.stream().map(TransferState::build).collect(Collectors.toList());
objectValidator.validate(TransferState.class, emptyTransferHistory);
}
return emptyTransferHistory;
}
protected abstract List doEvaluate();
public static class EmptyTransferHistoryDefault extends EmptyTransferHistory {
@Override
protected List doEvaluate() {
List emptyTransferHistory = new ArrayList<>();
return assignOutput(emptyTransferHistory);
}
protected List assignOutput(List emptyTransferHistory) {
return Optional.ofNullable(emptyTransferHistory)
.map(o -> o.stream().map(i -> i.prune()).collect(Collectors.toList()))
.orElse(null);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy