SimpleArrayMap { public V getOrDefault(Object key, V defaultValue) { final int index = indexOfKey(key); return index >= 0 ? (V) mArray[(index << 1) + 1] : defaultValue; } 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 getOrDefaultUsesDefaultWhenAbsent() { SimpleArrayMap<String, String> map = new SimpleArrayMap<>(); assertEquals("1", map.getOrDefault("one", "1")); }