Interface DifferenceNode

All Superinterfaces:
Iterable<DifferenceNode>
All Known Implementing Classes:
DifferenceNode.EmptyDifferenceNode, DifferenceNodes, LeafDifferenceNode, MapDifferenceNode

public interface DifferenceNode extends Iterable<DifferenceNode>
The result of a diff operation. Represents a single node in the object tree.
Author:
Peter Lamby
  • Method Details

    • visit

      <T> T visit(de.serra.so_dirty.difference.visit.DifferenceVisitor<T> visitor, DifferenceVisit<T> visit)
      Visits the current node.

      The children will be visited after this node has been visited.

      The visiting of children can be prevented by calling DifferenceVisit.dontGoDeeper() usually from the visitor.

      Type Parameters:
      T - The return type of the visit.
      Parameters:
      visitor - The visitor.
      visit - The visit.
      Returns:
      The DifferenceVisit.value().
    • getName

      String getName()
      The relative path inside the object tree.
      Returns:
      The path.
    • getTypes

      Set<DifferenceType> getTypes()
      Describes in what way the current node changed. Returns an empty set if there are no changes.
      Returns:
      The types of change if any.
    • getTypesRecursive

      default Set<DifferenceType> getTypesRecursive()
      All the DifferenceType in the hierarchy.
      Returns:
      all the DifferenceType in the hierarchy.
    • get

      default DifferenceNode get(String path)
      Gets a differenceNode specified by an expression.

      There is no specification for the expression language right now. Please take a look at the PathUtilTest to see how to use it.

      Parameters:
      path - The path expression.
      Returns:
      The difference node at the specified path.
    • getChildNullable

      @Nullable DifferenceNode getChildNullable(String name)
      Gets a direct child node in the object tree.

      Will return null if the child does not exist.

      Parameters:
      name - The name of the child node.
      Returns:
      The result of the desired node. May return null.
    • getChild

      default DifferenceNode getChild(String childName)
      Gets a direct child node in the object tree.

      Will always successfully return even if the node does not exist. In that case an empty result is returned.

      Parameters:
      childName - The name of the child node.
      Returns:
      The result of the desired node. Will return a result with no changes if the node does not exist.
    • isDifferent

      default boolean isDifferent(DifferenceType @Nullable ... types)
      Did the node change in one of the ways described by types.

      This method will only report a difference if it's one of the types. If types is null this methods checks for any difference. If types.length == 0 this method will always return false.

      Parameters:
      types - The types of difference to check for.
      Returns:
      true if there is a difference described by types false otherwise.
    • isDifferent

      default boolean isDifferent(String path, DifferenceType @Nullable ... types)
      Convenience method for
      differenceNode.getChild("myPath").isDifferent(types...);
      
      Parameters:
      path - The relative path of the desired node to be checked.
      types - The types of difference to check for.
      Returns:
      true if there is a difference described by types false otherwise.
    • isDifferentRecursive

      default boolean isDifferentRecursive(DifferenceType @Nullable ... types)
      Did the current node or one of its children change?

      This method will only report a difference if it's one of the types. If types is null this methods checks for any difference. If types.length == 0 this method will always return false.

      Parameters:
      types - The types of difference to check for.
      Returns:
      true if the current node or its children changed. false otherwise.