package com.ease.gsms.server.controllers.api.v1;

import com.ease.gsms.server.services.dispatch.Allocation;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

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

@JsonTypeInfo( use=JsonTypeInfo.Id.CLASS)
public class AllocationInfo {

    int totalMessageCount;

    List<TaskInfo> tasks;

    UUID allocationUuid;

    public AllocationInfo() {
    }

    public AllocationInfo(Allocation allocation) {
        totalMessageCount = allocation.getWeight();
        tasks = allocation.getTasks().stream().map(TaskInfo::new).collect(Collectors.toList());
        allocationUuid = allocation.getUuid();
    }

    public int getTotalMessageCount() {
        return totalMessageCount;
    }

    public void setTotalMessageCount(int totalMessageCount) {
        this.totalMessageCount = totalMessageCount;
    }

    public List<TaskInfo> getTasks() {
        return tasks;
    }

    public void setTasks(List<TaskInfo> tasks) {
        this.tasks = tasks;
    }

    public UUID getAllocationUuid() {
        return allocationUuid;
    }

}
