final class WeakKeySet
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
WeakKeySet.KeyAndSource |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<Key<?>,com.google.common.collect.Multiset<java.lang.Object>> |
backingMap |
private 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.
|
private 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.
|
Constructor and Description |
---|
WeakKeySet(java.lang.Object lock) |
Modifier and Type | Method and Description |
---|---|
void |
add(Key<?> key,
State state,
java.lang.Object source) |
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.
|
boolean |
contains(Key<?> key) |
java.util.Set<java.lang.Object> |
getSources(Key<?> key) |
private java.util.Map<Key<?>,com.google.common.collect.Multiset<java.lang.Object>> backingMap
private final java.lang.Object lock
private final com.google.common.cache.Cache<State,java.util.Set<WeakKeySet.KeyAndSource>> evictionCache
private void cleanUpForCollectedState(java.util.Set<WeakKeySet.KeyAndSource> keysAndSources)
public boolean contains(Key<?> key)
public java.util.Set<java.lang.Object> getSources(Key<?> key)