/** * Returns a flag whether the specified tracked node is detached. * * @param selector the {@code NodeSelector} * @return a flag whether this node is detached * @throws ConfigurationRuntimeException if no data for this selector is * available */ public boolean isTrackedNodeDetached(final NodeSelector selector) { return getTrackedNodeData(selector).isDetached(); }
/** * Returns the current {@code ImmutableNode} instance associated with the * given selector. * * @param selector the {@code NodeSelector} * @return the {@code ImmutableNode} selected by this selector * @throws ConfigurationRuntimeException if no data for this selector is * available */ public ImmutableNode getTrackedNode(final NodeSelector selector) { return getTrackedNodeData(selector).getNode(); }
/** * Returns the detached node model for the specified tracked node. When a * node becomes detached, operations on it are independent from the original * model. To implement this, a separate node model is created wrapping this * tracked node. This model can be queried by this method. If the node * affected is not detached, result is <b>null</b>. * * @param selector the {@code NodeSelector} * @return the detached node model for this node or <b>null</b> * @throws ConfigurationRuntimeException if no data for this selector is * available */ public InMemoryNodeModel getDetachedNodeModel(final NodeSelector selector) { return getTrackedNodeData(selector).getDetachedModel(); }
/** * Replaces a tracked node by another one. This operation causes the tracked * node to become detached. * * @param selector the {@code NodeSelector} * @param newNode the replacement node * @return the updated instance * @throws ConfigurationRuntimeException if the selector cannot be resolved */ public NodeTracker replaceAndDetachTrackedNode(final NodeSelector selector, final ImmutableNode newNode) { final Map<NodeSelector, TrackedNodeData> newState = new HashMap<>(trackedNodes); newState.put(selector, getTrackedNodeData(selector).detach(newNode)); return new NodeTracker(newState); }
/** * Notifies this object that an observer was removed for the specified * tracked node. If this was the last observer, the track data for this * selector can be removed. * * @param selector the {@code NodeSelector} * @return the updated instance * @throws ConfigurationRuntimeException if no information about this node * is available */ public NodeTracker untrackNode(final NodeSelector selector) { final TrackedNodeData trackData = getTrackedNodeData(selector); final Map<NodeSelector, TrackedNodeData> newState = new HashMap<>(trackedNodes); final TrackedNodeData newTrackData = trackData.observerRemoved(); if (newTrackData == null) { newState.remove(selector); } else { newState.put(selector, newTrackData); } return new NodeTracker(newState); }