org.simpleflatmapper.reflect.getter.StringEnumGetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-reflect Show documentation
Show all versions of sfm-reflect 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.reflect.getter;
import org.simpleflatmapper.reflect.Getter;
public final class StringEnumGetter> implements Getter {
private final Class enumType;
private final Getter stringGetter;
public StringEnumGetter(final Getter stringGetter, final Class enumType) {
this.stringGetter = stringGetter;
this.enumType = enumType;
}
@Override
public E get(final R target) throws Exception {
final String o = stringGetter.get(target);
return (E) Enum.valueOf(enumType, String.valueOf(o));
}
@Override
public String toString() {
return "StringEnumGetter{" +
"enumType=" + enumType +
", stringGetter=" + stringGetter +
'}';
}
}