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

org.simpleflatmapper.map.mapper.PropertyWithSetterOrConstructor 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.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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy