public T mapToDomainObject(CaseXml ccCase) { T instance = null; try { instance = clazz.newInstance(); BeanUtils.copyProperties(instance, ccCase); BeanUtils.populate(instance, ccCase.getFieldValues()); } catch (Exception e) { LOG.error(e.getMessage(), e); } return instance; }
public CaseXml mapFromDomainObject(T careCase) { CaseXml ccCase = new CaseXml(); try { BeanUtils.copyProperties(ccCase, careCase); BeanMap beanMap = new BeanMap(careCase); removeStaticProperties(beanMap); Map<String, String> valueMap = new HashMap<String, String>(); while (beanMap.keyIterator().hasNext()) { valueMap.put( (String) beanMap.keyIterator().next(), (String) beanMap.get((String) beanMap.keyIterator().next())); } ccCase.setFieldValues(valueMap); } catch (Exception e) { LOG.error(e.getMessage(), e); } return ccCase; }