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

space.maxus.flare.util.CompoundValidator Maven / Gradle / Ivy

The newest version!
package space.maxus.flare.util;

import lombok.Data;

import java.util.List;

/**
 * A compound validator that can validate multiple predicates at once
 */
@Data
public class CompoundValidator implements Validator {
    private final List passes;

    @Override
    public boolean isValid(String input) {
        return FlareUtil.reduceBoolStream(
                passes.stream().map(each -> each.isValid(input)),
                (a, b) -> a && b
        );
    }

    @Override
    public Validator and(Validator other) {
        // avoiding creating another CompoundValidator here
        this.passes.add(other);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy