Class WeakKeySet


  • final class WeakKeySet
    extends java.lang.Object
    Minimal set that doesn't hold strong references to the contained keys.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  WeakKeySet.KeyAndSource  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<Key<?>,​com.google.common.collect.Multiset<java.lang.Object>> backingMap  
      private com.google.common.cache.Cache<InjectorBindingData,​java.util.Set<WeakKeySet.KeyAndSource>> evictionCache
      Tracks child injector lifetimes and evicts banned 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 Summary

      Constructors 
      Constructor Description
      WeakKeySet​(java.lang.Object lock)  
    • 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<InjectorBindingData,​java.util.Set<WeakKeySet.KeyAndSource>> evictionCache
        Tracks child injector lifetimes and evicts banned keys/sources after the child injector is garbage collected.
    • Constructor Detail

      • WeakKeySet

        WeakKeySet​(java.lang.Object lock)
    • Method Detail

      • contains

        public boolean contains​(Key<?> key)
      • getSources

        public java.util.Set<java.lang.Object> getSources​(Key<?> key)