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

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


import org.simpleflatmapper.reflect.meta.PropertyMeta;
import org.simpleflatmapper.util.Predicate;

import static org.simpleflatmapper.util.Asserts.requireNonNull;

public class KeyProperty {

    private static final Predicate> DEFAULT_PREDICATE = new Predicate>() {
        @Override
        public boolean test(PropertyMeta propertyMeta) {
            return !propertyMeta.isSubProperty();
        }
    };

    public static final KeyProperty DEFAULT = new KeyProperty(DEFAULT_PREDICATE);

    private final Predicate> appliesTo;

    public KeyProperty() {
        this(DEFAULT_PREDICATE);
    }

    public KeyProperty(Predicate> appliesTo) {
        this.appliesTo = requireNonNull("appliesTo", appliesTo);
    }

    public Predicate> getAppliesTo() {
        return appliesTo;
    }

    @Override
    public String toString() {
        return "Key{" + appliesTo + "}";
    }

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

        KeyProperty that = (KeyProperty) o;

        return appliesTo.equals(that.appliesTo);

    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy