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

org.solidcoding.validation.api.VoidEndingValidator Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package org.solidcoding.validation.api;

import java.util.function.Function;

final class VoidEndingValidator extends AbstractLoggingValidator implements VoidValidator {

    private final Runnable runnable;

    VoidEndingValidator(Runnable runnable, ContinuingValidator validator) {
        super(validator);
        this.runnable = runnable;
    }

    @Override
    public  Void orElseThrow(Function throwableFunction) {
        var isValid = validator.validate();
        if (!isValid) {
            throw throwableFunction.apply(validator.getMessage());
        }
        runnable.run();
        return null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy