public static <K, V> V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier)
    {
        V value = map.get(key);
        if (value == null)
        {
            value = supplier.apply(key);
            map.put(key, value);
        }

        return value;
    }
@Test
    void getOrDefaultDoesNotCreateNewValueWhenOneExists()
    {
        final Map<Integer, Integer> values = new HashMap<>();
        values.put(0, 0);
        final Integer result = CollectionUtil.getOrDefault(
            values,
            0,
            (x) ->
            {
                fail("Shouldn't be called");
                return x + 1;
            });

        assertThat(result, is(0));
    }