@Test public void putIfAbsentReturnsNullWhenAbsent() { SparseArrayCompat<String> map = new SparseArrayCompat<>(); assertNull(map.putIfAbsent(1, "2")); }
@Nullable public E putIfAbsent(int key, E value) { E mapValue = get(key); if (mapValue == null) { put(key, value); } return mapValue; }
SparseArrayCompat implements Cloneable { @Nullable public E putIfAbsent(int key, E value) { E mapValue = get(key); if (mapValue == null) { put(key, value); } return mapValue; } }
SparseArrayCompat implements Cloneable { @Nullable public E putIfAbsent(int key, E value) { E mapValue = get(key); if (mapValue == null) { put(key, value); } return mapValue; } SparseArrayCompat();  SparseArrayCompat(int initialCapacity); }
SparseArrayCompat implements Cloneable { @Nullable public E putIfAbsent(int key, E value) { E mapValue = get(key); if (mapValue == null) { put(key, value); } return mapValue; } SparseArrayCompat();  SparseArrayCompat(int initialCapacity); @Override @SuppressWarnings("unchecked") SparseArrayCompat<E> clone(); @Nullable @SuppressWarnings("NullAway") // See inline comment. E get(int key); @SuppressWarnings("unchecked") E get(int key, E valueIfKeyNotFound); @Deprecated void delete(int key); void remove(int key); boolean remove(int key, Object value); void removeAt(int index); void removeAtRange(int index, int size); @Nullable E replace(int key, E value); boolean replace(int key, E oldValue, E newValue); void put(int key, E value); void putAll(@NonNull SparseArrayCompat<? extends E> other); @Nullable E putIfAbsent(int key, E value); int size(); boolean isEmpty(); int keyAt(int index); @SuppressWarnings("unchecked") E valueAt(int index); void setValueAt(int index, E value); int indexOfKey(int key); int indexOfValue(E value); boolean containsKey(int key); boolean containsValue(E value); void clear(); void append(int key, E value); @Override String toString(); }
SparseArrayCompat implements Cloneable { @Nullable public E putIfAbsent(int key, E value) { E mapValue = get(key); if (mapValue == null) { put(key, value); } return mapValue; } SparseArrayCompat();  SparseArrayCompat(int initialCapacity); @Override @SuppressWarnings("unchecked") SparseArrayCompat<E> clone(); @Nullable @SuppressWarnings("NullAway") // See inline comment. E get(int key); @SuppressWarnings("unchecked") E get(int key, E valueIfKeyNotFound); @Deprecated void delete(int key); void remove(int key); boolean remove(int key, Object value); void removeAt(int index); void removeAtRange(int index, int size); @Nullable E replace(int key, E value); boolean replace(int key, E oldValue, E newValue); void put(int key, E value); void putAll(@NonNull SparseArrayCompat<? extends E> other); @Nullable E putIfAbsent(int key, E value); int size(); boolean isEmpty(); int keyAt(int index); @SuppressWarnings("unchecked") E valueAt(int index); void setValueAt(int index, E value); int indexOfKey(int key); int indexOfValue(E value); boolean containsKey(int key); boolean containsValue(E value); void clear(); void append(int key, E value); @Override String toString();  }