Package com.google.inject.internal
Class WeakKeySet
- java.lang.Object
-
- com.google.inject.internal.WeakKeySet
-
final class WeakKeySet extends java.lang.ObjectMinimal set that doesn't hold strong references to the contained keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classWeakKeySet.KeyAndSource
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Key<?>,com.google.common.collect.Multiset<java.lang.Object>>backingMapprivate com.google.common.cache.Cache<State,java.util.Set<WeakKeySet.KeyAndSource>>evictionCacheTracks child injector lifetimes and evicts blacklisted keys/sources after the child injector is garbage collected.private java.lang.ObjectlockThis is already locked externally on add and getSources but we need it to handle clean up in the evictionCache's RemovalListener.
-
Constructor Summary
Constructors Constructor Description WeakKeySet(java.lang.Object lock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Key<?> key, State state, java.lang.Object source)private voidcleanUpForCollectedState(java.util.Set<WeakKeySet.KeyAndSource> keysAndSources)There may be multiple child injectors blacklisting a certain key so only remove the source that's relevant.booleancontains(Key<?> key)java.util.Set<java.lang.Object>getSources(Key<?> key)
-
-
-
Field Detail
-
backingMap
private java.util.Map<Key<?>,com.google.common.collect.Multiset<java.lang.Object>> backingMap
-
lock
private final java.lang.Object lock
This is already locked externally on add and getSources but we need it to handle clean up in the evictionCache's RemovalListener.
-
evictionCache
private final com.google.common.cache.Cache<State,java.util.Set<WeakKeySet.KeyAndSource>> evictionCache
Tracks child injector lifetimes and evicts blacklisted keys/sources after the child injector is garbage collected.
-
-
Method Detail
-
cleanUpForCollectedState
private void cleanUpForCollectedState(java.util.Set<WeakKeySet.KeyAndSource> keysAndSources)
There may be multiple child injectors blacklisting a certain key so only remove the source that's relevant.
-
contains
public boolean contains(Key<?> key)
-
getSources
public java.util.Set<java.lang.Object> getSources(Key<?> key)
-
-