org.sfm.reflect.meta.SubPropertyMeta Maven / Gradle / Ivy
Show all versions of simpleFlatMapper Show documentation
package org.sfm.reflect.meta;
import org.sfm.reflect.Getter;
import org.sfm.reflect.ReflectionService;
import org.sfm.reflect.Setter;
import java.lang.reflect.Type;
public class SubPropertyMeta extends PropertyMeta {
private final PropertyMeta ownerProperty;
private final PropertyMeta subProperty;
public SubPropertyMeta(ReflectionService reflectService, PropertyMeta property, PropertyMeta subProperty) {
super(property.getName(), property.getColumn(), reflectService);
this.ownerProperty = property;
this.subProperty = subProperty;
}
@Override
protected Setter newSetter() {
return ownerProperty.newSetter();
}
@Override
protected Getter newGetter() {
return ownerProperty.newGetter();
}
@Override
public Type getType() {
return ownerProperty.getType();
}
public PropertyMeta getOwnerProperty() {
return ownerProperty;
}
public PropertyMeta getSubProperty() {
return subProperty;
}
@Override
protected ClassMeta
newClassMeta() {
return ownerProperty.getClassMeta();
}
@Override
public boolean isSubProperty() {
return true;
}
@Override
public String getPath() {
return getOwnerProperty().getPath() + "." + subProperty.getPath();
}
@SuppressWarnings("unchecked")
public Type getLeafType() {
if (subProperty.isSubProperty()) {
return ((SubPropertyMeta
)subProperty).getLeafType();
} else {
return subProperty.getType();
}
}
@Override
public String toString() {
return "SubPropertyMeta{" +
"ownerProperty=" + ownerProperty +
", subProperty=" + subProperty +
'}';
}
}