Interface DifferenceEngineConfigurer<D extends DifferenceEngineConfigurer<D>>

All Known Implementing Classes:
CompareAssert, CompareMatcher, DiffBuilder

public interface DifferenceEngineConfigurer<D extends DifferenceEngineConfigurer<D>>
Subset of the configuration options available for a DifferenceEngine.
Since:
2.6.0
  • Method Details

    • withNodeMatcher

      D withNodeMatcher(NodeMatcher nodeMatcher)
      Sets the strategy for selecting nodes to compare.

      Example with DefaultNodeMatcher:

       .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
       
      See Also:
    • withDifferenceEvaluator

      D withDifferenceEvaluator(DifferenceEvaluator differenceEvaluator)
      Provide your own custom DifferenceEvaluator implementation.

      This overwrites the Default DifferenceEvaluator.

      If you want use your custom DifferenceEvaluator in combination with the default or another DifferenceEvaluator you should use DifferenceEvaluators.chain(DifferenceEvaluator...) or DifferenceEvaluators.first(DifferenceEvaluator...) to combine them:

               .withDifferenceEvaluator(
                   DifferenceEvaluators.chain(
                       DifferenceEvaluators.Default,
                       new MyCustomDifferenceEvaluator()))
               ....
       
    • withComparisonController

      D withComparisonController(ComparisonController comparisonController)
      Replace the ComparisonControllers#Default with your own ComparisonController.

      Example use:

            .withComparisonController(ComparisonControllers.StopWhenDifferent)
       
    • withComparisonListeners

      D withComparisonListeners(ComparisonListener... comparisonListeners)
      Registers listeners that are notified of each comparison.
      See Also:
    • withDifferenceListeners

      D withDifferenceListeners(ComparisonListener... comparisonListeners)
      Registers listeners that are notified of each comparison with outcome other than ComparisonResult.EQUAL.
      See Also:
    • withNamespaceContext

      D withNamespaceContext(Map<String,String> prefix2Uri)
      Establish a namespace context that will be used in Comparison.Detail#getXPath.

      Without a namespace context (or with an empty context) the XPath expressions will only use local names for elements and attributes.

      Parameters:
      prefix2Uri - mapping between prefix and namespace URI
    • withAttributeFilter

      D withAttributeFilter(Predicate<Attr> attributeFilter)
      Registers a filter for attributes.

      Only attributes for which the predicate returns true are part of the comparison. By default all attributes are considered.

      The "special" namespace, namespace-location and schema-instance-type attributes can not be ignored this way. If you want to suppress comparison of them you'll need to implement DifferenceEvaluator.

    • withNodeFilter

      D withNodeFilter(Predicate<Node> nodeFilter)
      Registers a filter for nodes.

      Only nodes for which the predicate returns true are part of the comparison. By default nodes that are not document types are considered.

    • withComparisonFormatter

      D withComparisonFormatter(ComparisonFormatter formatter)
      Sets a non-default formatter for the differences found.