Class BaseCachingSnapshotParser<S,​T>

  • All Implemented Interfaces:
    BaseSnapshotParser<S,​T>

    public abstract class BaseCachingSnapshotParser<S,​T>
    extends java.lang.Object
    implements BaseSnapshotParser<S,​T>
    Implementation of BaseSnapshotParser that caches results, so parsing a snapshot repeatedly is not expensive.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear all data in the cache.
      abstract java.lang.String getId​(S snapshot)
      Get a unique identifier for a snapshot, should not depend on snapshot content.
      void invalidate​(S snapshot)
      Invalidate the cache for a certain document.
      T parseSnapshot​(S snapshot)
      This method parses the Snapshot into the requested type.
      • Methods inherited from class java.lang.Object

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

      • BaseCachingSnapshotParser

        public BaseCachingSnapshotParser​(@NonNull
                                         BaseSnapshotParser<S,​T> parser)
    • Method Detail

      • getId

        @NonNull
        public abstract java.lang.String getId​(@NonNull
                                               S snapshot)
        Get a unique identifier for a snapshot, should not depend on snapshot content.
      • parseSnapshot

        @NonNull
        public T parseSnapshot​(@NonNull
                               S snapshot)
        Description copied from interface: BaseSnapshotParser
        This method parses the Snapshot into the requested type.
        Specified by:
        parseSnapshot in interface BaseSnapshotParser<S,​T>
        Parameters:
        snapshot - the Snapshot to extract the model from
        Returns:
        the model extracted from the DataSnapshot
      • clear

        public void clear()
        Clear all data in the cache.
      • invalidate

        public void invalidate​(@NonNull
                               S snapshot)
        Invalidate the cache for a certain document.