Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override Java 1.8 default Map methods in ObservableMap #1075

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.springframework.util.Assert;

Expand All @@ -43,7 +46,7 @@ public class ObservableMap<K, V> implements Map<K, V> {
public ObservableMap() {
// default constructor needed for kryo, thus
// we create delegate here, listener not needed.
delegate = new ConcurrentHashMap<K, V>();
delegate = new ConcurrentHashMap<>();
}

/**
Expand Down Expand Up @@ -132,6 +135,61 @@ public Set<java.util.Map.Entry<K, V>> entrySet() {
return delegate.entrySet();
}

@Override
public V getOrDefault(Object key, V defaultValue) {
return delegate.getOrDefault(key, defaultValue);
}

@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
delegate.forEach(action);
}

@Override
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
delegate.replaceAll(function);
}

@Override
public V putIfAbsent(K key, V value) {
return delegate.putIfAbsent(key, value);
}

@Override
public boolean remove(Object key, Object value) {
return delegate.remove(key, value);
}

@Override
public boolean replace(K key, V oldValue, V newValue) {
return delegate.replace(key, oldValue, newValue);
}

@Override
public V replace(K key, V value) {
return delegate.replace(key, value);
}

@Override
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
return delegate.computeIfAbsent(key, mappingFunction);
}

@Override
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
return delegate.computeIfPresent(key, remappingFunction);
}

@Override
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
return delegate.compute(key, remappingFunction);
}

@Override
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
return delegate.merge(key, value, remappingFunction);
}

@Override
public String toString() {
return delegate.toString();
Expand Down