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.entities.StatusPerkawinanPegawai;
import com.jasamedika.medifirst2000.vo.StatusPerkawinanPegawaiVO;
//import com.jasamedika.medifirst2000.entities.PasienPenyakit;

/**
 * Converter class between Pasien and PasienVO
 * 
 * @author Lukman Hakim
 */
@Component
public class StatusPerkawinanPegawaiConverter implements BaseVoConverter<StatusPerkawinanPegawaiVO, StatusPerkawinanPegawai> {


	@Override
	public StatusPerkawinanPegawai transferVOToModel(StatusPerkawinanPegawaiVO vo, StatusPerkawinanPegawai model) {
		if (null == model)
			model = new StatusPerkawinanPegawai();

		try {
			String[] fieldsToInclude = null;
			Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
			Gson gson = new Gson();
	        String json = gson.toJson(serialized);
	        model = gson.fromJson(json, StatusPerkawinanPegawai.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return model;
	}

	@Override
	public List<StatusPerkawinanPegawaiVO> transferListOfModelToListOfVO(List<StatusPerkawinanPegawai> models, List<StatusPerkawinanPegawaiVO> vos) {

		if (null == vos)
			vos = new ArrayList<StatusPerkawinanPegawaiVO>();

		if (null == models)
			return vos;

		for (StatusPerkawinanPegawai pegawai : models) {
			StatusPerkawinanPegawaiVO vo = new StatusPerkawinanPegawaiVO();
			vo=transferModelToVO(pegawai, vo);
			vos.add(vo);
		}

		return vos;
	}

	@Override
	public StatusPerkawinanPegawaiVO transferModelToVO(StatusPerkawinanPegawai model, StatusPerkawinanPegawaiVO vo) {
		if (null == vo)
			vo = new StatusPerkawinanPegawaiVO();
		try {
			String[] fieldsToInclude = null;
			Map<String, Object> serialized = model.serialize(fieldsToInclude,model.getClass().getSimpleName());
			Gson gson = new Gson();
	        String json = gson.toJson(serialized);
	        vo = gson.fromJson(json, StatusPerkawinanPegawaiVO.class);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return vo;
	}
	
	
	
	

}
