Class NodeHashMapImpl

  • All Implemented Interfaces:
    NodeHashMap

    public class NodeHashMapImpl
    extends java.lang.Object
    implements NodeHashMap
    a simple wrapper to ConcurrentHashMap that recalculates a digest after each mutation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear all the items stored inside this map.
      java.util.Set<java.util.Map.Entry<java.lang.String,​DataNode>> entrySet()
      Return all the entries inside this map.
      DataNode get​(java.lang.String path)
      Return the data node associated with the path.
      long getDigest()
      Return the digest value.
      void postChange​(java.lang.String path, DataNode node)
      Called after making the changes on the node, which will update the digest.
      void preChange​(java.lang.String path, DataNode node)
      Called before we made the change on the node, which will clear the digest associated with it.
      DataNode put​(java.lang.String path, DataNode node)
      Add the node into the map and update the digest with the new node.
      DataNode putWithoutDigest​(java.lang.String path, DataNode node)
      Add the node into the map without update the digest.
      DataNode remove​(java.lang.String path)
      Remove the path from the internal nodes map.
      int size()
      Return the size of the nodes stored in this map.
      • Methods inherited from class java.lang.Object

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

      • NodeHashMapImpl

        public NodeHashMapImpl​(DigestCalculator digestCalculator)
    • Method Detail

      • put

        public DataNode put​(java.lang.String path,
                            DataNode node)
        Description copied from interface: NodeHashMap
        Add the node into the map and update the digest with the new node.
        Specified by:
        put in interface NodeHashMap
        Parameters:
        path - the path of the node
        node - the actual node associated with this path
      • putWithoutDigest

        public DataNode putWithoutDigest​(java.lang.String path,
                                         DataNode node)
        Description copied from interface: NodeHashMap
        Add the node into the map without update the digest.
        Specified by:
        putWithoutDigest in interface NodeHashMap
        Parameters:
        path - the path of the node
        node - the actual node associated with this path
      • get

        public DataNode get​(java.lang.String path)
        Description copied from interface: NodeHashMap
        Return the data node associated with the path.
        Specified by:
        get in interface NodeHashMap
        Parameters:
        path - the path to read from
      • remove

        public DataNode remove​(java.lang.String path)
        Description copied from interface: NodeHashMap
        Remove the path from the internal nodes map.
        Specified by:
        remove in interface NodeHashMap
        Parameters:
        path - the path to remove
        Returns:
        the node being removed
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,​DataNode>> entrySet()
        Description copied from interface: NodeHashMap
        Return all the entries inside this map.
        Specified by:
        entrySet in interface NodeHashMap
      • clear

        public void clear()
        Description copied from interface: NodeHashMap
        Clear all the items stored inside this map.
        Specified by:
        clear in interface NodeHashMap
      • size

        public int size()
        Description copied from interface: NodeHashMap
        Return the size of the nodes stored in this map.
        Specified by:
        size in interface NodeHashMap
      • preChange

        public void preChange​(java.lang.String path,
                              DataNode node)
        Description copied from interface: NodeHashMap
        Called before we made the change on the node, which will clear the digest associated with it.
        Specified by:
        preChange in interface NodeHashMap
        Parameters:
        path - the path being changed
        node - the node associated with the path
      • postChange

        public void postChange​(java.lang.String path,
                               DataNode node)
        Description copied from interface: NodeHashMap
        Called after making the changes on the node, which will update the digest.
        Specified by:
        postChange in interface NodeHashMap
        Parameters:
        path - the path being changed
        node - the node associated with the path
      • getDigest

        public long getDigest()
        Description copied from interface: NodeHashMap
        Return the digest value.
        Specified by:
        getDigest in interface NodeHashMap