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

org.simpleflatmapper.map.CaseInsensitiveFieldKeyNamePredicate 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.map;

import org.simpleflatmapper.util.Named;
import org.simpleflatmapper.util.OrManyPredicate;
import org.simpleflatmapper.util.Predicate;

public final class CaseInsensitiveFieldKeyNamePredicate implements Predicate>, Named {
    private final String name;

    private CaseInsensitiveFieldKeyNamePredicate(String name) {
        this.name = name;
    }

    @Override
    public boolean test(FieldKey fieldKey) {
        return fieldKey.getName().equalsIgnoreCase(name);
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "CaseInsensitiveFieldKeyNamePredicate{" +
                "name='" + name + '\'' +
                '}';
    }

    public static CaseInsensitiveFieldKeyNamePredicate of(String name) {
        return new CaseInsensitiveFieldKeyNamePredicate(name);
    }

    public static Predicate> any(String... name) {
        CaseInsensitiveFieldKeyNamePredicate[] predicates = new CaseInsensitiveFieldKeyNamePredicate[name.length];

        for (int i = 0; i < name.length; i++) {
            String n = name[i];
            predicates[i] = CaseInsensitiveFieldKeyNamePredicate.of(n);
        }

        return new OrManyPredicate>(predicates);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy