package com.jasamedika.medifirst2000.converter; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.springframework.stereotype.Component; import com.google.gson.Gson; import com.jasamedika.medifirst2000.converter.base.BaseVoConverter; import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao; import com.jasamedika.medifirst2000.entities.PapRiwayatKeluarga; import com.jasamedika.medifirst2000.vo.PapRiwayatKeluargaVO; /** * Converter class PAPRiwayatKeluarga * * @author Askur */ @Component public class PapRiwayatKeluargaConverter extends FindConverterDao implements BaseVoConverter { public PapRiwayatKeluarga transferVOToModel(PapRiwayatKeluargaVO vo, PapRiwayatKeluarga model) { if (null == model) model = new PapRiwayatKeluarga(); try { String[] fieldsToInclude = null; Map serialized = vo.serialize(fieldsToInclude,vo.getClass().getName()); Gson gson = new Gson(); String json = gson.toJson(serialized); model = gson.fromJson(json, PapRiwayatKeluarga.class); } catch (Exception e) { e.printStackTrace(); } return model; } public List transferListOfModelToListOfVO(List models, List vos) { if (null == vos) vos = new ArrayList(); if (null == models) return vos; for (PapRiwayatKeluarga model : models) { PapRiwayatKeluargaVO vo = new PapRiwayatKeluargaVO(); transferModelToVO(model, vo); vos.add(vo); } return vos; } public PapRiwayatKeluargaVO transferModelToVO(PapRiwayatKeluarga model, PapRiwayatKeluargaVO vo) { if (null == vo) vo = new PapRiwayatKeluargaVO(); try { String[] fieldsToInclude = null; Map serialized = model.serialize(fieldsToInclude,model.getClass().getName()); Gson gson = new Gson(); String json = gson.toJson(serialized); vo = gson.fromJson(json, PapRiwayatKeluargaVO.class); } catch (Exception e) { e.printStackTrace(); } return vo; } }