Salman Manoe 593613a753 Update Generate Comment @author
Perbaikan author untuk salman
2021-12-21 12:57:51 +07:00

73 lines
1.9 KiB
Java

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.StatusPegawai;
import com.jasamedika.medifirst2000.vo.StatusPegawaiVO;
/**
* Converter class between Jabatan and JabatanVO
*
* @author salmanoe
*/
@Component
public class StatusPegawaiConverter implements BaseVoConverter<StatusPegawaiVO, StatusPegawai> {
@Override
public StatusPegawai transferVOToModel(StatusPegawaiVO vo, StatusPegawai model) {
if (null == model)
model = new StatusPegawai();
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, StatusPegawai.class);
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
@Override
public List<StatusPegawaiVO> transferListOfModelToListOfVO(List<StatusPegawai> models, List<StatusPegawaiVO> vos) {
if (null == vos)
vos = new ArrayList<StatusPegawaiVO>();
if (null == models)
return vos;
for (StatusPegawai statusPegawai : models) {
StatusPegawaiVO vo = new StatusPegawaiVO();
vo = transferModelToVO(statusPegawai, vo);
vos.add(vo);
}
return vos;
}
@Override
public StatusPegawaiVO transferModelToVO(StatusPegawai model, StatusPegawaiVO vo) {
if (null == vo)
vo = new StatusPegawaiVO();
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, StatusPegawaiVO.class);
} catch (Exception e) {
e.printStackTrace();
}
return vo;
}
}