org.simpleflatmapper.reflect.getter.StringEnumGetter Maven / Gradle / Ivy
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 +
'}';
}
}