SimpleArrayMap { @Nullable public V putIfAbsent(K key, V value) { V mapValue = get(key); if (mapValue == null) { mapValue = put(key, value); } return mapValue; } SimpleArrayMap(); @SuppressWarnings("NullAway") // allocArrays initializes mHashes and mArray.  SimpleArrayMap(int capacity);  SimpleArrayMap(SimpleArrayMap<K, V> map); void clear(); void ensureCapacity(int minimumCapacity); boolean containsKey(@Nullable Object key); int indexOfKey(@Nullable Object key); boolean containsValue(Object value); @Nullable @SuppressWarnings("NullAway") // See inline comment. V get(Object key); V getOrDefault(Object key, V defaultValue); K keyAt(int index); V valueAt(int index); V setValueAt(int index, V value); boolean isEmpty(); @Nullable V put(K key, V value); void putAll(@NonNull SimpleArrayMap<? extends K, ? extends V> array); @Nullable V putIfAbsent(K key, V value); @Nullable V remove(Object key); boolean remove(Object key, Object value); V removeAt(int index); @Nullable V replace(K key, V value); boolean replace(K key, V oldValue, V newValue); int size(); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString();  }
@Test public void putIfAbsentReturnsNullWhenAbsent() { SimpleArrayMap<String, String> map = new SimpleArrayMap<>(); assertNull(map.putIfAbsent("one", "2")); }