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

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

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

import java.util.function.Predicate;

final class RuleDefinitionBuilder implements RuleBuilder {

    private final Predicate rule;

    public RuleDefinitionBuilder(Predicate rule) {
        this.rule = rule;
    }

    public RuleBuilder and(Predicate rule) {
        return this;
    }

    public Rule otherWiseReport(String failMessage, Object... formatArguments) {
        if (formatArguments != null) {
            var actualMessage = String.format(failMessage, formatArguments);
            return new RuleDefinition<>(rule, actualMessage);
        }
        return new RuleDefinition<>(rule, failMessage);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy