class NonNegativeIntegerSplitterByWeights {

    public ImmutableMap<E, Integer> split(int numberToSplit) {
        Preconditions.checkArgument(numberToSplit >= 0, "Quantity to split must be non negative");

        if (proportions.isEmpty()) {
            return ImmutableMap.of();
        }

        ImmutableMap<E, Double> idealAmounts = ImmutableMapFactory.createWithNewValues(
                proportions,
                p -> p * numberToSplit);

        ImmutableMap<E, Integer> roundedDownAmounts = ImmutableMapFactory.createWithNewValues(
                idealAmounts,
                idealAmount -> (int) Math.floor(idealAmount));

        return assignRemainder(numberToSplit, idealAmounts, roundedDownAmounts);
    }

    public  NonNegativeIntegerSplitterByWeights(ImmutableMap<E, Double> weights);

}