Class NodeTracker.TrackedNodeData

java.lang.Object
org.apache.commons.configuration2.tree.NodeTracker.TrackedNodeData
Enclosing class:
NodeTracker

private static final class NodeTracker.TrackedNodeData extends Object
A simple data class holding information about a tracked node.
  • Field Details

    • node

      private final ImmutableNode node
      The current instance of the tracked node.
    • observerCount

      private final int observerCount
      The number of observers of this tracked node.
    • detachedModel

      private final InMemoryNodeModel detachedModel
      A node model to be used when the tracked node is detached.
  • Constructor Details

    • TrackedNodeData

      public TrackedNodeData(ImmutableNode nd)
      Creates a new instance of TrackedNodeData and initializes it with the current reference to the tracked node.
      Parameters:
      nd - the tracked node
    • TrackedNodeData

      private TrackedNodeData(ImmutableNode nd, int obsCount, InMemoryNodeModel detachedNodeModel)
      Creates a new instance of TrackedNodeData and initializes its properties.
      Parameters:
      nd - the tracked node
      obsCount - the observer count
      detachedNodeModel - a model to be used in detached mode
  • Method Details

    • getNode

      public ImmutableNode getNode()
      Gets the tracked node.
      Returns:
      the tracked node
    • getDetachedModel

      public InMemoryNodeModel getDetachedModel()
      Gets the node model to be used in detached mode. This is null if the represented tracked node is not detached.
      Returns:
      the node model in detached mode
    • isDetached

      public boolean isDetached()
      Returns a flag whether the represented tracked node is detached.
      Returns:
      the detached flag
    • observerAdded

      public NodeTracker.TrackedNodeData observerAdded()
      Another observer was added for this tracked node. This method returns a new instance with an adjusted observer count.
      Returns:
      the updated instance
    • observerRemoved

      public NodeTracker.TrackedNodeData observerRemoved()
      An observer for this tracked node was removed. This method returns a new instance with an adjusted observer count. If there are no more observers, result is null. This means that this node is no longer tracked and can be released.
      Returns:
      the updated instance or null
    • updateNode

      public NodeTracker.TrackedNodeData updateNode(ImmutableNode newNode)
      Updates the node reference. This method is called after an update of the underlying node structure if the tracked node was replaced by another instance.
      Parameters:
      newNode - the new tracked node instance
      Returns:
      the updated instance
    • detach

      public NodeTracker.TrackedNodeData detach(ImmutableNode newNode)
      Returns an instance with the detached flag set to true. This method is called if the selector of a tracked node does not match a single node any more. It is possible to pass in a new node instance which becomes the current tracked node. If this is null, the previous node instance is used.
      Parameters:
      newNode - the new tracked node instance (may be null)
      Returns:
      the updated instance