package com.pack.modeler.assembler;

import com.pack.modeler.dto.ArtifactDTO;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class ArtifactAssembler {
    public Resource<ArtifactDTO> toResource(String artifact, List<String> elements) {
        ArtifactDTO dto = new ArtifactDTO(artifact, elements);

        return new Resource<>(dto);
    }

    public Resources toResources(Map<String, List<String>> map){
        List<ArtifactDTO> artifactList = new ArrayList<>();

        map.forEach((k,v) -> artifactList.add(new ArtifactDTO(k,v)));

        return new Resources(artifactList);
    }
}
