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.PapSkriningGiziDetail;
import com.jasamedika.medifirst2000.vo.PapSkriningGiziDetailVO;

/**
 * Converter class between PAPSkriningGiziDetail and PAPSkriningGiziDetailVO
 * 
 * @author Askur
 */
@Component
public class PapSkriningGiziDetailConverter implements BaseVoConverter<PapSkriningGiziDetailVO, PapSkriningGiziDetail> {
	

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

	}

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

		if (null == models)
			return vos;

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

		return vos;
	}

	@Override
	public PapSkriningGiziDetailVO transferModelToVO(PapSkriningGiziDetail model, PapSkriningGiziDetailVO vo) {

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

		return vo;
	
	}

	
}
