Class BeanCache<Q extends java.lang.annotation.Annotation,​T>

  • All Implemented Interfaces:
    java.io.Serializable

    final class BeanCache<Q extends java.lang.annotation.Annotation,​T>
    extends java.util.concurrent.atomic.AtomicReference<java.lang.Object>
    Atomic cache mapping Bindings to BeanEntrys; optimized for common case of single entries.

    Uses == instead of equals to compare Bindings because we want referential equality.

    • Constructor Summary

      Constructors 
      Constructor Description
      BeanCache()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Iterable<com.google.inject.Binding<T>> bindings()
      Retrieves the Binding references currently associated with BeanEntrys.
      BeanEntry<Q,​T> create​(Q qualifier, com.google.inject.Binding<T> binding, int rank)
      Atomically creates a new BeanEntry for the given Binding reference.
      private static java.util.Map createMap​(LazyBeanEntry one, LazyBeanEntry two)  
      java.util.Map<com.google.inject.Binding<T>,​BeanEntry<Q,​T>> flush()  
      BeanEntry<Q,​T> remove​(com.google.inject.Binding<T> binding)
      Removes the BeanEntry associated with the given Binding reference.
      • Methods inherited from class java.util.concurrent.atomic.AtomicReference

        accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • readCache

        private java.util.Map<com.google.inject.Binding<T>,​BeanEntry<Q extends java.lang.annotation.Annotation,​T>> readCache
      • mutated

        private volatile boolean mutated
    • Constructor Detail

      • BeanCache

        BeanCache()
    • Method Detail

      • create

        public BeanEntry<Q,​T> create​(Q qualifier,
                                           com.google.inject.Binding<T> binding,
                                           int rank)
        Atomically creates a new BeanEntry for the given Binding reference.
        Parameters:
        qualifier - The qualifier
        binding - The binding
        rank - The assigned rank
        Returns:
        Associated bean entry
      • flush

        public java.util.Map<com.google.inject.Binding<T>,​BeanEntry<Q,​T>> flush()
        Returns:
        Read-only snapshot of the cache
      • bindings

        public java.lang.Iterable<com.google.inject.Binding<T>> bindings()
        Retrieves the Binding references currently associated with BeanEntrys.
        Returns:
        Associated bindings
      • remove

        public BeanEntry<Q,​T> remove​(com.google.inject.Binding<T> binding)
        Removes the BeanEntry associated with the given Binding reference.
        Parameters:
        binding - The binding
        Returns:
        Associated bean entry