org.simpleflatmapper.map.property.KeyProperty Maven / Gradle / Ivy
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