Class AbstractDecoratedNodeState

    • Field Detail

      • delegate

        protected final NodeState delegate
    • Constructor Detail

      • AbstractDecoratedNodeState

        protected AbstractDecoratedNodeState​(@NotNull
                                             @NotNull NodeState delegate,
                                             boolean useNativeEquals)
    • Method Detail

      • getDelegate

        public NodeState getDelegate()
      • hideChild

        protected boolean hideChild​(@NotNull
                                    @NotNull java.lang.String name,
                                    @NotNull
                                    @NotNull NodeState delegateChild)
      • decorateChild

        @NotNull
        protected abstract @NotNull NodeState decorateChild​(@NotNull
                                                            @NotNull java.lang.String name,
                                                            @NotNull
                                                            @NotNull NodeState delegateChild)
      • hideProperty

        protected boolean hideProperty​(@NotNull
                                       @NotNull java.lang.String name)
      • getNewPropertyStates

        @NotNull
        protected @NotNull java.lang.Iterable<PropertyState> getNewPropertyStates()
      • decorateProperty

        @Nullable
        protected abstract @Nullable PropertyState decorateProperty​(@NotNull
                                                                    @NotNull PropertyState delegatePropertyState)
      • fixChildOrderPropertyState

        protected static PropertyState fixChildOrderPropertyState​(NodeState nodeState,
                                                                  PropertyState propertyState)
        Convenience method to help implementations that hide nodes set the :childOrder (OAK_CHILD_ORDER) property to its correct value.
        Intended to be used to implement decorateProperty(PropertyState).
        Parameters:
        nodeState - The current node state.
        propertyState - The property that chould be checked.
        Returns:
        The original propertyState, unless the property is called :childOrder.
      • builder

        @NotNull
        public @NotNull NodeBuilder builder()
        The AbstractDecoratedNodeState implementation returns a ReadOnlyBuilder, which will fail for any mutable operation. This method can be overridden to return a different NodeBuilder implementation.
        Returns:
        a NodeBuilder instance corresponding to this NodeState.
      • exists

        public boolean exists()
        Description copied from interface: NodeState
        Checks whether this node exists. See the above discussion about the existence of node states.
        Returns:
        true if this node exists, false if not
      • hasChildNode

        public boolean hasChildNode​(@NotNull
                                    @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Checks whether the named child node exists. The implementation is equivalent to getChildNode(name).exists(), except that passing an invalid name as argument will result in a false return value instead of an IllegalArgumentException.
        Parameters:
        name - name of the child node
        Returns:
        true if the named child node exists, false otherwise
      • getChildNode

        @NotNull
        public @NotNull NodeState getChildNode​(@NotNull
                                               @NotNull java.lang.String name)
                                        throws java.lang.IllegalArgumentException
        Description copied from interface: NodeState
        Returns the named, possibly non-existent, child node. Use the NodeState.exists() method on the returned child node to determine whether the node exists or not.
        Parameters:
        name - name of the child node to return
        Returns:
        named child node
        Throws:
        java.lang.IllegalArgumentException - if the given name string is is empty or contains a forward slash character
      • getChildNodeEntries

        @NotNull
        public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
        Description copied from interface: NodeState
        Returns the iterable child node entries of this instance. Multiple iterations are guaranteed to return the child nodes in the same order, but the specific order used is implementation dependent and may change across different states of the same node.

        Note on cost and performance: while it is possible to iterate over all child NodeStates with the two methods NodeState.getChildNodeNames() and NodeState.getChildNode(String), this method is considered more efficient because an implementation can potentially perform the retrieval of the name and NodeState in one call. This results in O(n) vs. O(n log n) when iterating over the child node names and then look up the NodeState by name.

        Returns:
        child node entries in some stable order
      • getProperty

        @Nullable
        public @Nullable PropertyState getProperty​(@NotNull
                                                   @NotNull java.lang.String name)
        Description copied from interface: NodeState
        Returns the named property, or null if no such property exists.
        Specified by:
        getProperty in interface NodeState
        Overrides:
        getProperty in class AbstractNodeState
        Parameters:
        name - name of the property to return
        Returns:
        named property, or null if not found
      • getProperties

        @NotNull
        public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
        Description copied from interface: NodeState
        Returns an iterable of the properties of this node. Multiple iterations are guaranteed to return the properties in the same order, but the specific order used is implementation-dependent and may change across different states of the same node.
        Returns:
        properties in some stable order
      • equals

        public boolean equals​(java.lang.Object other)
        Note that any implementation-specific optimizations of wrapped NodeStates will not work if a AbstractDecoratedNodeState is passed into their #equals() method. This implementation will compare the wrapped NodeState, however. So optimizations work when calling #equals() on a ReportingNodeState.
        Overrides:
        equals in class AbstractNodeState
        Parameters:
        other - Object to compare with this NodeState.
        Returns:
        true if the given object is equal to this NodeState, false otherwise.
      • compareAgainstBaseState

        public boolean compareAgainstBaseState​(NodeState base,
                                               NodeStateDiff diff)
        Description copied from class: AbstractNodeState
        Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.
        Specified by:
        compareAgainstBaseState in interface NodeState
        Overrides:
        compareAgainstBaseState in class AbstractNodeState
        Parameters:
        base - base state
        diff - handler of node state differences
        Returns:
        true if the full diff was performed, or false if it was aborted as requested by the handler (see the NodeStateDiff contract for more details)