Class ReportingNodeState

  • All Implemented Interfaces:
    NodeState

    public class ReportingNodeState
    extends AbstractDecoratedNodeState
    A decoration layer for NodeState instances that intercepts all accesses to NodeStates and PropertyStates (getters) and informs a Reporter via its callbacks that the respective NodeStates or PropertyStates have been accessed.
    The decoration is deep, i.e. any child NodeStates will be decorated as well and will report to the same Reporter instance.
    For convenience, a PeriodicReporter abstract class exists. This simplifies reporting every nth node/property only.
    Note: Multiple accesses to the same node or property are each reported. Therefore if exactly counting unique accesses is a requirement, the reporter needs to take care of de-duplication.
    See Also:
    Reporter, PeriodicReporter, LoggingReporter
    • Method Detail

      • wrap

        public static NodeState wrap​(NodeState nodeState,
                                     Reporter reporter)
        Allows wrapping a NodeState as a ReportingNodeState. The wrapped NodeState is treated as the root of a tree (i.e. path is "/").
        Any children accessed via this NodeState are also wrapped. Each wrapped NodeState is also reported to the provided Reporter.
        Parameters:
        nodeState - The NodeState to be wrapped.
        reporter - The reporter to report to.
        Returns:
        the wrapped NodeState.
      • getPath

        public java.lang.String getPath()
        ReportingNodeState instances provide access to their path via their parent hierarchy. Note that calculating the path on every access may incur a significant performance penalty.
        Returns:
        The path of the ReportingNodeState instance, assuming that the first wrapped instance is the root node.
      • toString

        public java.lang.String toString()
        Description copied from class: AbstractNodeState
        Returns a string representation of this node state.
        Overrides:
        toString in class AbstractNodeState
        Returns:
        string representation