All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.vault.transit.VaultBatchException Maven / Gradle / Ivy

There is a newer version: 3.0.0.Beta1
Show newest version
package io.quarkus.vault.transit;

import static java.util.stream.Collectors.toMap;

import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;

import io.quarkus.vault.VaultException;
import io.quarkus.vault.runtime.transit.VaultTransitBatchResult;

/**
 * Base class for batch exceptions.
 */
public abstract class VaultBatchException extends VaultException {

    protected  Map filter(Map results, Predicate predicate,
            Function function) {
        return results.entrySet().stream()
                .filter(entry -> predicate.test(entry.getValue()))
                .collect(toMap(Map.Entry::getKey, entry -> function.apply(entry.getValue())));
    }

    protected  Map getErrors(Map results) {
        return filter(results, VaultTransitBatchResult::isInError, VaultTransitBatchResult::getError);
    }

    protected  Map getValid(Map results) {
        return filter(results, VaultTransitBatchResult::isValid, VaultTransitBatchResult::getValue);
    }

    public VaultBatchException(String message) {
        super(message);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy