package com.thesis.centralserver.entities.mappers;

import com.thesis.centralserver.dtos.OffloadingTaskDTO;
import com.thesis.centralserver.entities.OffloadingTask;

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

public class OffloadingTaskMapper {

    public static OffloadingTaskDTO createTaskDTO(OffloadingTask offloadingTask) {

        OffloadingTaskDTO offloadingTaskDTO = new OffloadingTaskDTO();
        offloadingTaskDTO.setId(offloadingTask.getId());
        offloadingTaskDTO.setIp(offloadingTask.getSeller().getIp());
        offloadingTaskDTO.setCost(offloadingTask.getCost());
        offloadingTaskDTO.setStatus(offloadingTask.getStatus());

        return offloadingTaskDTO;

    }

    public static List<OffloadingTaskDTO> createTaskDTOList(Collection<OffloadingTask> tasks) {

        return tasks.stream()
                .map(OffloadingTaskMapper::createTaskDTO)
                .collect(Collectors.toList());

    }

}
