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

com.jfirer.jsql.transfer.column.impl.EnumNameTransfer Maven / Gradle / Ivy

package com.jfirer.jsql.transfer.column.impl;

import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;

public class EnumNameTransfer extends AbstractColumnTransfer
{
    @SuppressWarnings("rawtypes")
    private Class type;

    @Override
    @SuppressWarnings({"unchecked", "rawtypes"})
    public void initialize(Field field, String columnName)
    {
        super.initialize(field, columnName);
        type = (Class) field.getType();
    }

    @SuppressWarnings("unchecked")
    @Override
    public void setEntityValue(Object entity, ResultSet resultSet) throws SQLException, IllegalArgumentException, IllegalAccessException
    {
        String value = resultSet.getString(columnName);
        if ( resultSet.wasNull() == false )
        {
            field.set(entity, Enum.valueOf(type, value));
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy