Class BeanCache<Q extends Annotation,T>

All Implemented Interfaces:
Serializable

final class BeanCache<Q extends Annotation,T> extends AtomicReference<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.

  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • readCache

      private Map<com.google.inject.Binding<T>,BeanEntry<Q extends Annotation,T>> readCache
    • mutated

      private volatile boolean mutated
  • Constructor Details

    • BeanCache

      BeanCache()
  • Method Details

    • 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 Map<com.google.inject.Binding<T>,BeanEntry<Q,T>> flush()
      Returns:
      Read-only snapshot of the cache
    • bindings

      public 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
    • createMap

      private static Map createMap(LazyBeanEntry one, LazyBeanEntry two)