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

org.simpleflatmapper.util.OrManyPredicate Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.util;

import java.util.Arrays;

public final class OrManyPredicate implements Predicate {
    public final Predicate[] predicates;

    public OrManyPredicate(Predicate... predicates) {
        this.predicates = predicates;
    }

    @Override
    public boolean test(T t) {
        for (Predicate predicate : predicates) {
            if (predicate.test(t)) return true;
        }
        return false;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        OrManyPredicate that = (OrManyPredicate) o;

        // Probably incorrect - comparing Object[] arrays with Arrays.equals
        return Arrays.equals(predicates, that.predicates);
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(predicates);
    }

    @Override
    public String toString() {
        return "OrManyPredicate{" +
                "predicates=" + Arrays.toString(predicates) +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy