org.sfm.reflect.meta.DirectClassMeta Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.reflect.meta;
import org.sfm.map.MapperBuildingException;
import org.sfm.reflect.InstantiatorDefinition;
import org.sfm.reflect.Getter;
import org.sfm.reflect.ReflectionService;
import org.sfm.reflect.Setter;
import org.sfm.reflect.impl.NullSetter;
import java.lang.reflect.Type;
import java.util.Collections;
import java.util.List;
public final class DirectClassMeta implements ClassMeta {
public static final String[] HEADERS = new String[]{""};
private final ReflectionService reflectService;
private final Type target;
public DirectClassMeta(Type target, ReflectionService reflectService) throws MapperBuildingException {
this.target = target;
this.reflectService = reflectService;
}
@Override
public ReflectionService getReflectionService() {
return reflectService;
}
@Override
public PropertyFinder newPropertyFinder() {
return new DirectPropertyFinder();
}
@Override
public Type getType() {
return target;
}
@Override
public String[] generateHeaders() {
return HEADERS;
}
@Override
public boolean isLeaf() {
return true;
}
@Override
public List getInstantiatorDefinitions() {
return Collections.emptyList();
}
public class DirectPropertyFinder implements PropertyFinder {
@Override
public PropertyMeta findProperty(PropertyNameMatcher propertyNameMatcher) {
return new DirectPropertyMeta("direct", reflectService, target);
}
@Override
public List getEligibleInstantiatorDefinitions() {
return null;
}
@Override
public ConstructorPropertyMeta findConstructor(InstantiatorDefinition instantiatorDefinition) {
return null;
}
}
public class DirectPropertyMeta extends PropertyMeta {
private final Type type;
public DirectPropertyMeta(String name, ReflectionService reflectService, Type type) {
super(name, reflectService);
this.type = type;
}
@Override
protected Setter newSetter() {
return NullSetter.setter();
}
@Override
protected Getter newGetter() {
throw new UnsupportedOperationException();
}
@Override
public Type getType() {
return type;
}
@Override
public String getPath() {
return ".";
}
@Override
public String toString() {
return "DirectPropertyMeta{" +
"type=" + type +
'}';
}
}
@Override
public String toString() {
return "DirectClassMeta{" +
"target=" + target +
'}';
}
}