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

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

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

import org.slf4j.Logger;

public abstract class AbstractLoggingValidator implements LoggingValidator {

    protected final ContinuingValidator validator;

    protected AbstractLoggingValidator(ContinuingValidator validator) {
        this.validator = validator;
    }

    @Override
    public void orElseLogInfo(Logger logger) {
        var isValid = validator.validate();
        if (!isValid) {
            logger.info(validator.getMessage());
        }
    }

    @Override
    public void orElseLogWarn(Logger logger) {
        var isValid = validator.validate();
        if (!isValid) {
            logger.warn(validator.getMessage());
        }
    }

    @Override
    public void orElseLogError(Logger logger) {
        var isValid = validator.validate();
        if (!isValid) {
            logger.error(validator.getMessage());
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy