package com.eksad.masterdata.domain.assembler; import com.eksad.ddms.common.dto.CreationalSpecificationDTO; import com.eksad.ddms.common.util.object.IObjectAssembler; import com.eksad.ddms.common.util.status.DataStatus; import com.eksad.masterdata.common.dto.PromoPosDTO; import com.eksad.masterdata.domain.CreationalSpecification; import com.eksad.masterdata.domain.PromoPos; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class PromoPosAssembler implements IObjectAssembler<PromoPos, PromoPosDTO> { @Override public PromoPosDTO toDTO(PromoPos x) { return new PromoPosDTO( x.getPosServiceID(), x.getPosServiceName(), x.getPromoPosID(), x.getPromoPosStatus(), x.getPromoID(), x.getAhassID(), x.getPromoPosCreational() == null ? new CreationalSpecificationDTO() : new CreationalSpecificationDTOAssembler().toDTO(x.getPromoPosCreational()) ); } @Override public PromoPos toDomain(PromoPosDTO y) { return new PromoPos( y.getPosServiceID(), y.getPosServiceName(), y.getPromoPosID(), y.getPromoPosStatus(), y.getPromoID(), y.getAhassID(), y.getPromoPosCreationalDTO() == null ? new CreationalSpecification() : new CreationalSpecificationDTOAssembler().toDomain(y.getPromoPosCreationalDTO()) ); } public List<PromoPosDTO> toDTOs(Set<PromoPos> arg0) { List<PromoPosDTO> res = new ArrayList<>(); arg0.stream().filter(o -> DataStatus.ACTIVE.equals(o.getPromoPosStatus())).forEach((o) -> { res.add(toDTO(o)); }); return res; } public List<PromoPosDTO> toDTOs(List<PromoPos> arg0) { List<PromoPosDTO> res = new ArrayList<>(); arg0.stream().filter(o -> DataStatus.ACTIVE.equals(o.getPromoPosStatus())).forEach((o) -> { res.add(toDTO(o)); }); return res; } public Set<PromoPos> toDomains(List<PromoPosDTO> arg0) { Set<PromoPos> res = new HashSet<>(); arg0.stream().forEach((o) -> { res.add(toDomain(o)); }); return res; } }