package com.jasamedika.medifirst2000.logging;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ObjectUtil {
	
	private ObjectUtil() {}
	
	public static Map<String, Object> getColumnNamesAndValues(final Object object) 
			throws IllegalArgumentException, IllegalAccessException {
		Class<? extends Object> c = object.getClass();
		
		Map<String, Object> map = new HashMap<>();
		for (Field field : c.getDeclaredFields()) {
			field.setAccessible(true);
			String name = field.getName();
			Object value = field.get(object);
			map.put(name, value);
		}
		return map;
	}

}
