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 aDifferenceEngine
.- Since:
- 2.6.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description D
withAttributeFilter(Predicate<org.w3c.dom.Attr> attributeFilter)
Registers a filter for attributes.D
withComparisonController(ComparisonController comparisonController)
Replace theComparisonControllers.Default
with your own ComparisonController.D
withComparisonFormatter(ComparisonFormatter formatter)
Sets a non-default formatter for the differences found.D
withComparisonListeners(ComparisonListener... comparisonListeners)
Registers listeners that are notified of each comparison.D
withDifferenceEvaluator(DifferenceEvaluator differenceEvaluator)
Provide your own customDifferenceEvaluator
implementation.D
withDifferenceListeners(ComparisonListener... comparisonListeners)
Registers listeners that are notified of each comparison with outcome other thanComparisonResult.EQUAL
.D
withNamespaceContext(java.util.Map<java.lang.String,java.lang.String> prefix2Uri)
Establish a namespace context that will be used inComparison.Detail#getXPath
.D
withNodeFilter(Predicate<org.w3c.dom.Node> nodeFilter)
Registers a filter for nodes.D
withNodeMatcher(NodeMatcher nodeMatcher)
Sets the strategy for selecting nodes to compare.
-
-
-
Method Detail
-
withNodeMatcher
D withNodeMatcher(NodeMatcher nodeMatcher)
Sets the strategy for selecting nodes to compare.Example with
DefaultNodeMatcher
:.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText))
This overwrites any
NodeMatcher
set via earlier invocations ofwithNodeMatcher
.- Parameters:
nodeMatcher
- the NodeMatcher to use- Returns:
- this
- See Also:
DifferenceEngine.setNodeMatcher(NodeMatcher)
-
withDifferenceEvaluator
D withDifferenceEvaluator(DifferenceEvaluator differenceEvaluator)
Provide your own customDifferenceEvaluator
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...)
orDifferenceEvaluators.first(DifferenceEvaluator...)
to combine them:.withDifferenceEvaluator( DifferenceEvaluators.chain( DifferenceEvaluators.Default, new MyCustomDifferenceEvaluator())) ....
This overwrites any
DifferenceEvaluator
set via earlier invocations ofwithDifferenceEvaluator
.- Parameters:
differenceEvaluator
- the DifferenceEvaluator to use- Returns:
- this
-
withComparisonController
D withComparisonController(ComparisonController comparisonController)
Replace theComparisonControllers.Default
with your own ComparisonController.Example use:
.withComparisonController(ComparisonControllers.StopWhenDifferent)
This overwrites any
ComparisonController
set via earlier invocations ofwithComparisonController
.- Parameters:
comparisonController
- ComparisonController to use- Returns:
- this
-
withComparisonListeners
D withComparisonListeners(ComparisonListener... comparisonListeners)
Registers listeners that are notified of each comparison.- Parameters:
comparisonListeners
- ComparisonListeners to use- Returns:
- this
- See Also:
This overwrites any s set via earlier invocations of .
-
withDifferenceListeners
D withDifferenceListeners(ComparisonListener... comparisonListeners)
Registers listeners that are notified of each comparison with outcome other thanComparisonResult.EQUAL
.This overwrites any
ComparisonListener
s set via earlier invocations ofwithDifferenceListeners
.- Parameters:
comparisonListeners
- ComparisonListeners to use- Returns:
- this
- See Also:
DifferenceEngine.addDifferenceListener(ComparisonListener)
-
withNamespaceContext
D withNamespaceContext(java.util.Map<java.lang.String,java.lang.String> prefix2Uri)
Establish a namespace context that will be used inComparison.Detail#getXPath
.Without a namespace context (or with an empty context) the XPath expressions will only use local names for elements and attributes.
This overwrites any
Map
set via earlier invocations ofwithNamespaceContext
.- Parameters:
prefix2Uri
- mapping between prefix and namespace URI- Returns:
- this
-
withAttributeFilter
D withAttributeFilter(Predicate<org.w3c.dom.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
.This overwrites any
Predicate
set via earlier invocations ofwithAttributeFilter
.- Parameters:
attributeFilter
- attribute filter to use- Returns:
- this
-
withNodeFilter
D withNodeFilter(Predicate<org.w3c.dom.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.
This overwrites any
Predicate
set via earlier invocations ofwithNodeFilter
.- Parameters:
nodeFilter
- node filter to use- Returns:
- this
-
withComparisonFormatter
D withComparisonFormatter(ComparisonFormatter formatter)
Sets a non-default formatter for the differences found.This overwrites any
ComparisonFormatter
set via earlier invocations ofwithComparisonFormatter
.- Parameters:
formatter
- formatter to use- Returns:
- this
-
-