package net.mstezala.services.models.Slots;


import net.mstezala.services.models.Nominal;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

public class CoinSlot extends Slot<Nominal> {

    public Nominal getNominalWithActualLargestCoinNumber() {
        if (getObjectNumber().isEmpty()) {
            throw new IllegalArgumentException("CoinSlot is empty");
        }

        Map.Entry<Nominal, Integer> actualLargestsNominalEntry = getObjectNumber().entrySet().stream().max((n1, n2) -> n1.getValue() - n2.getValue()).get();
        return actualLargestsNominalEntry.getKey();
    }

    public Collection<Nominal> getNominalTypes() {
        return getObjectNumber().keySet().stream().sorted().collect(Collectors.toList());
    }


    public BigDecimal sumCoins() {
        BigDecimal result = BigDecimal.ZERO;
        if (getObjectNumber().isEmpty()) {
            return result;
        }
        for (Map.Entry<Nominal, Integer> set : getObjectNumber().entrySet()) {
            result = result.add(set.getKey().getValue().multiply(BigDecimal.valueOf(set.getValue())));
        }
        return result;
    }


}

@@ -253,408 +253,8 @@
  %7B%0A%0A
-    public Nominal getNominalWithActualLargestCoinNumber() %7B%0A        if (getObjectNumber().isEmpty()) %7B%0A            throw new IllegalArgumentException(%22CoinSlot is empty%22);%0A        %7D%0A%0A        Map.Entry%3CNominal, Integer%3E actualLargestsNominalEntry = getObjectNumber().entrySet().stream().max((n1, n2) -%3E n1.getValue() - n2.getValue()).get();%0A        return actualLargestsNominalEntry.getKey();%0A    %7D%0A%0A
     
@@ -397,17 +397,16 @@
 %0A    %7D%0A%0A
-%0A
     publ

remove unused method