use of alfio.model.result.Result.ResultStatus in project alf.io by alfio-event.
the class AdminReservationManager method reduceResults.
private <T> Result<T> reduceResults(Result<T> r1, Result<T> r2, BiFunction<T, T, T> processData) {
boolean successful = r1.isSuccess() && r2.isSuccess();
ResultStatus global = r1.isSuccess() ? r2.getStatus() : r1.getStatus();
List<ErrorCode> errors = new ArrayList<>();
if (!successful) {
errors.addAll(r1.getErrors());
errors.addAll(r2.getErrors());
return new Result<>(global, null, errors);
} else {
return new Result<>(global, processData.apply(r1.getData(), r2.getData()), errors);
}
}
Aggregations