Class DifferenceNodes

java.lang.Object
de.serra.so_dirty.difference.DifferenceNodes
All Implemented Interfaces:
DifferenceNode, Iterable<DifferenceNode>

public class DifferenceNodes extends Object implements DifferenceNode
Multiple differences. Like an array or a class with fields.
Author:
Peter Lamby
  • Constructor Details

    • DifferenceNodes

      public DifferenceNodes(String name, @Nullable Character pathSeparator, DifferenceType @Nullable ... types)
      Constructs.
      Parameters:
      name - The relative path of this difference.
      pathSeparator - The separator to include when visiting.
      types - The types of difference for this node. Can be null.
    • DifferenceNodes

      public DifferenceNodes(String name, DifferenceType @Nullable ... types)
      Constructs.
      Parameters:
      name - The relative path of this difference.
      types - The types of difference for this node. Can be null.
  • Method Details

    • visit

      public <T> T visit(de.serra.so_dirty.difference.visit.DifferenceVisitor<T> visitor, DifferenceVisit<T> visit)
      Description copied from interface: DifferenceNode
      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.

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

      public String getName()
      Description copied from interface: DifferenceNode
      The relative path inside the object tree.
      Specified by:
      getName in interface DifferenceNode
      Returns:
      The path.
    • getTypes

      public Set<DifferenceType> getTypes()
      Description copied from interface: DifferenceNode
      Describes in what way the current node changed. Returns an empty set if there are no changes.
      Specified by:
      getTypes in interface DifferenceNode
      Returns:
      The types of change if any.
    • getChildNullable

      public @Nullable DifferenceNode getChildNullable(String name)
      Description copied from interface: DifferenceNode
      Gets a direct child node in the object tree.

      Will return null if the child does not exist.

      Specified by:
      getChildNullable in interface DifferenceNode
      Parameters:
      name - The name of the child node.
      Returns:
      The result of the desired node. May return null.
    • add

      public void add(DifferenceNode difference)
      Add a child difference.
      Parameters:
      difference - The child.
    • iterator

      public Iterator<DifferenceNode> iterator()
      Specified by:
      iterator in interface Iterable<DifferenceNode>