package com.pack.modeler.assembler;

import com.pack.modeler.dto.LogRowDTO;
import com.pack.modeler.structures.LogRow;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class LogRowAssembler {
    public Resource<LogRowDTO> toResource(LogRow row) {
        LogRowDTO dto = new LogRowDTO();

        dto.setNames(row.getNames());
        dto.setTypes(row.getTypes());
        dto.setValues(row.getValues());

        return new Resource<>(dto);
    }

    public Resources toResources(List<LogRow> rows){
        return new Resources(
                rows.stream().map(this::toResource).collect(Collectors.toList())
        );
    }
}
