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

org.simpleflatmapper.reflect.getter.StringEnumGetter Maven / Gradle / Ivy

Go to download

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 +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy