add proper wildcards for evictionListener

GitOrigin-RevId: ef7935a01801e338697ac67bc2d3afe83ea23b02
This commit is contained in:
Gregory.Shrago
2024-02-22 00:46:38 +04:00
committed by intellij-monorepo-bot
parent 8956447cc9
commit 5a24626e03
5 changed files with 22 additions and 8 deletions

View File

@@ -41,13 +41,13 @@ public final class CollectionFactory {
@Contract(value = "_ -> new", pure = true)
public static @NotNull <K, V> ConcurrentMap<@NotNull K, @NotNull V> createConcurrentWeakValueMap(
@NotNull Consumer<K> evictionListener) {
@NotNull Consumer<? super K> evictionListener) {
return new ConcurrentWeakValueHashMap<>(evictionListener);
}
@Contract(value = "_ -> new", pure = true)
public static @NotNull <K, V> ConcurrentMap<@NotNull K, @NotNull V> createConcurrentSoftValueMap(
@NotNull Consumer<K> evictionListener) {
@NotNull Consumer<? super K> evictionListener) {
return new ConcurrentSoftValueHashMap<>(evictionListener);
}

View File

@@ -20,10 +20,10 @@ import java.util.function.Consumer;
abstract class ConcurrentRefValueHashMap<K, V> implements ConcurrentMap<K, V> {
private final ConcurrentMap<K, ValueReference<K, V>> myMap = new ConcurrentHashMap<>();
private final Consumer<K> myEvictionListener;
private final Consumer<? super K> myEvictionListener;
protected final ReferenceQueue<V> myQueue = new ReferenceQueue<>();
ConcurrentRefValueHashMap(@Nullable Consumer<K> evictionListener) {
ConcurrentRefValueHashMap(@Nullable Consumer<? super K> evictionListener) {
myEvictionListener = evictionListener;
}

View File

@@ -16,7 +16,7 @@ import java.util.function.Consumer;
*/
final class ConcurrentSoftValueHashMap<K,V> extends ConcurrentRefValueHashMap<K,V> {
ConcurrentSoftValueHashMap(@Nullable Consumer<K> evictionListener) {
ConcurrentSoftValueHashMap(@Nullable Consumer<? super K> evictionListener) {
super(evictionListener);
}

View File

@@ -17,7 +17,7 @@ import java.util.function.Consumer;
*/
final class ConcurrentWeakValueHashMap<K,V> extends ConcurrentRefValueHashMap<K,V> {
ConcurrentWeakValueHashMap(@Nullable Consumer<K> evictionListener) {
ConcurrentWeakValueHashMap(@Nullable Consumer<? super K> evictionListener) {
super(evictionListener);
}