@SuppressWarnings("unchecked")
    public V replace(final int key, final V value)
    {
        final V val = (V)mapNullValue(value);
        requireNonNull(val, "value cannot be null");

        final int[] keys = this.keys;
        final Object[] values = this.values;
        @DoNotSub final int mask = values.length - 1;
        @DoNotSub int index = Hashing.hash(key, mask);

        Object oldValue;
        while (null != (oldValue = values[index]))
        {
            if (key == keys[index])
            {
                values[index] = val;
                break;
            }

            index = ++index & mask;
        }

        return unmapNullValue(oldValue);
    }
@Test
    void replaceThrowsNullPointerExceptionIfNewValueIsNull()
    {
        final NullPointerException exception =
            assertThrowsExactly(NullPointerException.class, () -> intToObjectMap.replace(42, "abc", null));
        assertEquals("value cannot be null", exception.getMessage());
    }