package org.hso.ecommerce.supplier.data;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class DeliveryManager {

    private List<Delivery> deliveryList;
    private static DeliveryManager deliveryManager;

    private DeliveryManager()
    {
        deliveryList = new ArrayList<>();
    }

    public static DeliveryManager getInstance () {

        if (DeliveryManager.deliveryManager == null) {
            DeliveryManager.deliveryManager = new DeliveryManager();
        }
        return DeliveryManager.deliveryManager;
    }

    public boolean add(Delivery delivery)
    {
       return deliveryList.add(delivery);
    }

    public Delivery getDeliveryByeID(String uuid)
    {
        return deliveryList.parallelStream().filter(d -> d.getUuid().equals(UUID.fromString(uuid))).findAny().get();
    }
}
