Class IdNameCache<T>

  • Type Parameters:
    T - the type of the key value held by the cache
    All Implemented Interfaces:
    IIdNameCache<T>

    public class IdNameCache<T>
    extends java.lang.Object
    implements IIdNameCache<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      IdNameCache()
      Public constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntry​(T id, java.lang.String name)
      Add the entry to the local cache
      void clearLocalMaps()
      Clear anything cached in thread-local (after transaction rollback, for example)
      java.util.Collection<java.lang.String> getAllNames()
      Get all names in the cache
      java.lang.String getName​(T key)
      Get the name for the given id
      void prefill​(java.util.Map<T,​java.lang.String> content)
      Prefill the shared map with the given content (must come data already committed in the database)
      void reset()
      Clear both local shared caches - useful for unit tests
      void updateSharedMaps()
      Called after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IdNameCache

        public IdNameCache()
        Public constructor
    • Method Detail

      • updateSharedMaps

        public void updateSharedMaps()
        Description copied from interface: IIdNameCache
        Called after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.
        Specified by:
        updateSharedMaps in interface IIdNameCache<T>
      • getName

        public java.lang.String getName​(T key)
        Description copied from interface: IIdNameCache
        Get the name for the given id
        Specified by:
        getName in interface IIdNameCache<T>
        Returns:
      • getAllNames

        public java.util.Collection<java.lang.String> getAllNames()
        Description copied from interface: IIdNameCache
        Get all names in the cache
        Specified by:
        getAllNames in interface IIdNameCache<T>
        Returns:
      • addEntry

        public void addEntry​(T id,
                             java.lang.String name)
        Description copied from interface: IIdNameCache
        Add the entry to the local cache
        Specified by:
        addEntry in interface IIdNameCache<T>
      • reset

        public void reset()
        Description copied from interface: IIdNameCache
        Clear both local shared caches - useful for unit tests
        Specified by:
        reset in interface IIdNameCache<T>
      • clearLocalMaps

        public void clearLocalMaps()
        Description copied from interface: IIdNameCache
        Clear anything cached in thread-local (after transaction rollback, for example)
        Specified by:
        clearLocalMaps in interface IIdNameCache<T>
      • prefill

        public void prefill​(java.util.Map<T,​java.lang.String> content)
        Description copied from interface: IIdNameCache
        Prefill the shared map with the given content (must come data already committed in the database)
        Specified by:
        prefill in interface IIdNameCache<T>