Skip to content

Commit

Permalink
Simplify UnmodifiableMutableMap by making more methods delegate.
Browse files Browse the repository at this point in the history
  • Loading branch information
motlin committed Jul 13, 2018
1 parent b78270f commit af465c0
Showing 1 changed file with 3 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,13 @@ public <P> V getIfAbsentPutWith(
@Override
public V getIfAbsent(K key, Function0<? extends V> function)
{
V result = this.get(key);
if (this.isAbsent(result, key))
{
return function.value();
}
return result;
return this.getMutableMap().getIfAbsent(key, function);
}

@Override
public V getIfAbsentValue(K key, V value)
{
V result = this.get(key);
if (this.isAbsent(result, key))
{
return value;
}
return result;
return this.getMutableMap().getIfAbsentValue(key, value);
}

@Override
Expand All @@ -244,12 +234,7 @@ public <P> V getIfAbsentWith(
Function<? super P, ? extends V> function,
P parameter)
{
V result = this.get(key);
if (this.isAbsent(result, key))
{
return function.valueOf(parameter);
}
return result;
return this.getMutableMap().getIfAbsentWith(key, function, parameter);
}

private boolean isAbsent(V result, K key)
Expand Down

0 comments on commit af465c0

Please sign in to comment.