package kr.gmtc.gw.dev.asderecv.asde.utils;

import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;

public class FieldNameReflectionUtils {

		
	public String getItem(Object obj, String sFieldName) {
		
		String sRetValue = "";
		
		Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
		
		if(field != null) {
			field.setAccessible(true);
			
			try {
				
				sRetValue = (String) ReflectionUtils.getField(field, obj);
				
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		}
		
		return sRetValue;
		
	}
	
	
	public void setItem(Object obj, String sFieldName, String sValue) {
		
		Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
		
		if(field != null) {
			field.setAccessible(true);
			
			try {
				ReflectionUtils.setField(field, obj, sValue);
			} catch (Exception e) {
				e.printStackTrace();
			}
			
		}
		
	}
	
}