Class NodeStateCopier


  • public class NodeStateCopier
    extends java.lang.Object
    The NodeStateCopier and NodeStateCopier.Builder classes allow recursively copying a NodeState to a NodeBuilder.
    The copy algorithm is optimized for copying nodes between two different NodeStore instances, i.e. where comparing NodeStates is imprecise and/or expensive.
    The algorithm does a post-order traversal. I.e. it copies changed leaf-nodes first.
    The work for a traversal without any differences between source and target is equivalent to the single execution of a naive equals implementation.
    Usage: For most use-cases the Builder API should be preferred. It allows setting includePaths, excludePaths and mergePaths.
    Include paths: if include paths are set, only these paths and their sub-trees are copied. Any nodes that are not within the scope of an include path are implicitly excluded.
    Exclude paths: if exclude paths are set, any nodes matching or below the excluded path are not copied. If an excluded node does exist in the target, it is removed (see also merge paths). Exclude fragments: if exclude fragments are set, nodes with names matching any of the fragments (and their subtrees) are not copied. If an excluded node does exist in the target, it is removed. Merge paths: if merge paths are set, any nodes matching or below the merged path will not be deleted from target, even if they are missing in (or excluded from) the source. Preserve on Target if set to true the nodes on target under the included paths are not deleted and the merge paths property is ignored. If false the deletion rules default to the case for merge paths.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  NodeStateCopier.Builder
      The NodeStateCopier.Builder allows configuring a NodeState copy operation with includePaths, excludePaths and mergePaths.
    • Method Detail

      • copyProperties

        public static boolean copyProperties​(NodeState source,
                                             NodeBuilder target)
        Copies all changed properties from the source NodeState to the target NodeBuilder instance.
        Parameters:
        source - The NodeState to copy from.
        target - The NodeBuilder to copy to.
        Returns:
        Whether changes were made or not.