org.simpleflatmapper.map.mapper.PropertyWithSetterOrConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-map Show documentation
Show all versions of sfm-map Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.simpleflatmapper.map.mapper;
import org.simpleflatmapper.reflect.meta.SubPropertyMeta;
import org.simpleflatmapper.reflect.setter.NullSetter;
import org.simpleflatmapper.reflect.meta.PropertyMeta;
import org.simpleflatmapper.util.Predicate;
public class PropertyWithSetterOrConstructor implements Predicate> {
public static final PropertyWithSetterOrConstructor INSTANCE = new PropertyWithSetterOrConstructor();
private PropertyWithSetterOrConstructor() {
}
@Override
public boolean test(PropertyMeta, ?> propertyMeta) {
if (propertyMeta.isSelf()) {
return true;
}
if (!NullSetter.isNull(propertyMeta.getSetter())) {
return true;
}
if (propertyMeta.isConstructorProperty()) {
return true;
}
if (propertyMeta.isSubProperty()) {
SubPropertyMeta subPropertyMeta = (SubPropertyMeta) propertyMeta;
if (subPropertyMeta.getOwnerProperty().isConstructorProperty()
|| !NullSetter.isNull(subPropertyMeta.getOwnerProperty().getSetter())) {
return test(subPropertyMeta.getSubProperty());
}
}
return false;
}
}