package com.akikanellis.kata01.offer;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public final class Offers {
    private final List<OfferWithQuantity> offersWithQuantities;

    private Offers(List<OfferWithQuantity> offersWithQuantities) { this.offersWithQuantities = offersWithQuantities; }

    public static Offers fromList(List<OfferWithQuantity> itemsWithQuantities) {
        return new Offers(itemsWithQuantities);
    }

    public static Offers fromEntries(Set<Map.Entry<Offer, Integer>> entries) {
        List<OfferWithQuantity> itemsWithQuantities = entries.stream()
                .map(entry -> OfferWithQuantity.create(entry.getKey(), entry.getValue()))
                .collect(Collectors.toList());

        return new Offers(itemsWithQuantities);
    }

    public static Offers empty() { return new Offers(Collections.emptyList()); }

    public List<OfferWithQuantity> asList() { return new ArrayList<>(offersWithQuantities); }

    public Offers join(Offers other) {
        List<OfferWithQuantity> joinedOfferWithQuantities = new ArrayList<>();

        List<OfferWithQuantity> otherOfferWithQuantities = other.asList();
        joinedOfferWithQuantities.addAll(offersWithQuantities);
        joinedOfferWithQuantities.addAll(otherOfferWithQuantities);

        return Offers.fromList(joinedOfferWithQuantities);
    }
}

@@ -116,88 +116,8 @@
 ist;
-%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.stream.Collectors;
 %0A%0Apu
@@ -467,351 +467,8 @@
  %7D%0A%0A
-    public static Offers fromEntries(Set%3CMap.Entry%3COffer, Integer%3E%3E entries) %7B%0A        List%3COfferWithQuantity%3E itemsWithQuantities = entries.stream()%0A                .map(entry -%3E OfferWithQuantity.create(entry.getKey(), entry.getValue()))%0A                .collect(Collectors.toList());%0A%0A        return new Offers(itemsWithQuantities);%0A    %7D%0A%0A
     

Remove unused fromEntries