Search in sources :

Example 1 with ResultStatus

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);
    }
}
Also used : ResultStatus(alfio.model.result.Result.ResultStatus) ErrorCode(alfio.model.result.ErrorCode) Result(alfio.model.result.Result)

Aggregations

ErrorCode (alfio.model.result.ErrorCode)1 Result (alfio.model.result.Result)1 ResultStatus (alfio.model.result.Result.ResultStatus)1