@Override public V putIfAbsentElseReturnPresent(K key, V value) { Require.that(key != null).orThrow("The key may not be null.", key); Require.that(value != null).orThrow("The value may not be null.", value); V result = super.putIfAbsentElseReturnPresent(key, value); Ensure.that(result != null).orThrow("The result may not be null.", result); return result; }
@Override public <KEY, EXCEPTION extends Exception> FreezableMap<KEY, E> toFreezableMap(FailableUnaryFunction<? super E, ? extends KEY, ? extends EXCEPTION> function) throws EXCEPTION { Require.that(function != null).orThrow("The function may not be null.", function); FreezableMap<KEY, E> result = super.toFreezableMap(function); Ensure.that(result != null).orThrow("The result may not be null.", result); Ensure.that(result == null || !result.isFrozen()).orThrow("The result has to be null or may not be frozen.", result); return result; }
@Override public V putIfAbsentOrNullElseReturnPresent(K key, V value) { Require.that(value != null).orThrow("The value may not be null.", value); Require.that(!isFrozen()).orThrow("The method 'putIfAbsentOrNullElseReturnPresent' may only be called on non-frozen objects."); V result = super.putIfAbsentOrNullElseReturnPresent(key, value); Ensure.that(result != null).orThrow("The result may not be null.", result); return result; }
@Override public VALUE get(KEY key) { Require.that(key != null).orThrow("The key may not be null.", key); Require.that(key == null || isValidKey(key)).orThrow("The key has to be null or valid but was $.", key); VALUE result = super.get(key); Ensure.that(result == null || isValid(result)).orThrow("The result has to be null or valid but was $.", result); return result; }