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

no.difi.certvalidator.structure.Junction Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
package no.difi.certvalidator.structure;

import no.difi.certvalidator.api.ValidatorRule;

import java.util.Arrays;
import java.util.List;

/**
 * Allows combining instances of validators using a limited set of logic.
 */
public interface Junction {

    static ValidatorRule and(ValidatorRule... validatorRules) {
        return and(Arrays.asList(validatorRules));
    }

    static ValidatorRule and(List validatorRules) {
        if (validatorRules.size() == 1)
            return validatorRules.get(0);
        return new AndJunction(validatorRules);
    }

    static ValidatorRule or(ValidatorRule... validatorRules) {
        return or(Arrays.asList(validatorRules));
    }

    static ValidatorRule or(List validatorRules) {
        if (validatorRules.size() == 1)
            return validatorRules.get(0);
        return new OrJunction(validatorRules);
    }

    static ValidatorRule xor(ValidatorRule... validatorRules) {
        return xor(Arrays.asList(validatorRules));
    }

    static ValidatorRule xor(List validatorRules) {
        if (validatorRules.size() == 1)
            return validatorRules.get(0);
        return new XorJunction(validatorRules);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy