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.PapGigiKiriTiga;
import com.jasamedika.medifirst2000.vo.PapGigiKiriTigaVO;

/**
 * Converter class between PAPGigiKiriTiga and PAPGigiKiriTigaVO
 * 
 * @author Askur
 */
@Component
public class PapGigiKiriTigaConverter implements BaseVoConverter<PapGigiKiriTigaVO, PapGigiKiriTiga> {
	

	public PapGigiKiriTiga transferVOToModel(PapGigiKiriTigaVO vo, PapGigiKiriTiga model) {
		if (null == model)
			model = new PapGigiKiriTiga();
		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, PapGigiKiriTiga.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return model;

	}

	public List<PapGigiKiriTigaVO> transferListOfModelToListOfVO(List<PapGigiKiriTiga> models,
			List<PapGigiKiriTigaVO> vos) {
		if (null == vos)
			vos = new ArrayList<PapGigiKiriTigaVO>();

		if (null == models)
			return vos;

		for (PapGigiKiriTiga PapGigiKiriTiga : models) {
			PapGigiKiriTigaVO vo = new PapGigiKiriTigaVO();
			vo = transferModelToVO(PapGigiKiriTiga, vo);
			vos.add(vo);
		}

		return vos;
	}

	@Override
	public PapGigiKiriTigaVO transferModelToVO(PapGigiKiriTiga model, PapGigiKiriTigaVO vo) {

		if (null == vo)
			vo = new PapGigiKiriTigaVO();
		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, PapGigiKiriTigaVO.class);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return vo;
	
	}

	
}
