package com.smartdot.cgt.model; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class BaseModel implements Serializable { /** * */ private static final long serialVersionUID = 1L; public Object get(String fieldName, Class < ? extends BaseModel > clazz) { Object value = ""; try { Method method = clazz.getMethod("get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1)); value = method.invoke(this); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return value; } }