@Test public void getOrDefaultUsesSupplier() { final Map<Integer, Integer> values = new HashMap<>(); final Integer result = CollectionUtil.getOrDefault(values, 0, (x) -> x + 1); assertThat(result, is(1)); }
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; }
CollectionUtil { 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; } }
CollectionUtil { 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; } private  CollectionUtil(); }
CollectionUtil { 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; } private  CollectionUtil(); static V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier); static int sum(final List<V> values, final ToIntFunction<V> function); static void validateLoadFactor(final float loadFactor); static void validatePositivePowerOfTwo(final int value); static int removeIf(final List<T> values, final Predicate<T> predicate); }
CollectionUtil { 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; } private  CollectionUtil(); static V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier); static int sum(final List<V> values, final ToIntFunction<V> function); static void validateLoadFactor(final float loadFactor); static void validatePositivePowerOfTwo(final int value); static int removeIf(final List<T> values, final Predicate<T> predicate);  }