Class DifferenceHelper

java.lang.Object
com.orchestranetworks.service.comparison.DifferenceHelper

public class DifferenceHelper extends Object
This class is the common entry point for performing data comparisons.

Resolved mode

When resolved mode is used:

  1. Inheritance is taken into account, meaning that if two values are inherited and different, a difference is detected
  2. Computed fields are also taken into account.

Conversely, disabling the resolved mode means to focus on the raw persisted data:

  1. Inheritance is not taken into account. If two values are both inherited, then they are not considered to be different because they are both equal to AdaptationValue.INHERIT_VALUE (result is independent of the values actually inherited).
  2. Computed fields are ignored.

Node comparison modes

A terminal node can have a comparison mode, which controls whether or not it is included during comparisons. Node that have the comparison mode ignored are not omitted from comparisons, even if their values contain differences.
See Also:
  • NodeComparisonMode
  • Constructor Details

    • DifferenceHelper

      public DifferenceHelper()
  • Method Details

    • compareHomes

      public static DifferenceBetweenHomes compareHomes(AdaptationHome leftHome, AdaptationHome rightHome, boolean isResolvedMode)
      Compares two dataspaces or snapshots and returns the result.
      Parameters:
      leftHome - dataspace or snapshot on left to use for comparison.
      rightHome - dataspace or snapshot on right to use for comparison.
      isResolvedMode - specifies whether or not the comparison is in resolved mode.
      Throws:
      IllegalArgumentException - if one of the specified arguments is not defined.
    • compareInstances

      public static DifferenceBetweenInstances compareInstances(Adaptation instanceOnLeft, Adaptation instanceOnRight, boolean isResolvedMode)
      Performs a comparison between two datasets.
      Parameters:
      instanceOnLeft - dataset on left to use for comparison.
      instanceOnRight - dataset on right to use for comparison.
      isResolvedMode - specifies whether the comparison is in resolved mode.
      Throws:
      IllegalArgumentException - if one of the specified arguments is not defined.
    • compareAdaptationTables

      public static DifferenceBetweenTables compareAdaptationTables(AdaptationTable tableOnLeft, AdaptationTable tableOnRight, boolean isResolvedMode)
      Performs a comparison between two tables.
      Parameters:
      tableOnLeft - table on left to use for comparison.
      tableOnRight - table on right to use for comparison.
      isResolvedMode - specifies whether the comparison is in resolved mode.
      Throws:
      IllegalArgumentException - if one of the specified arguments is not defined or if tables do not have the same primary key definition.
    • compareOccurrences

      public static DifferenceBetweenOccurrences compareOccurrences(Adaptation recordOnLeft, Adaptation recordOnRight, boolean isResolvedMode)
      Performs a comparison between two records.

      This method is equivalent to compareOccurrences(recordOnLeft, recordOnRight, isResolvedMode, false). That is, it does show details on terminal complex nodes.

      Parameters:
      recordOnLeft - record on left to use for comparison.
      recordOnRight - record on right to use for comparison.
      isResolvedMode - specifies whether the comparison is in resolved mode.
      Throws:
      IllegalArgumentException - if one of the specified arguments is not defined.
    • compareOccurrences

      public static DifferenceBetweenOccurrences compareOccurrences(Adaptation recordOnLeft, Adaptation recordOnRight, boolean isResolvedMode, boolean showDetails)
      Performs a comparison between two records.
      Parameters:
      recordOnLeft - record on left to use for comparison.
      recordOnRight - record on right to use for comparison.
      isResolvedMode - specifies whether the comparison is in resolved mode.
      showDetails - if true, differences on terminal complex nodes are detailed; if false, comparison stops on terminal node elements even if they are complex. showDetails is forced to false if isResolvedMode is set to false.
      Throws:
      IllegalArgumentException - if one of the specified arguments is not defined.