public class OverrideCombiner extends NodeCombiner
A concrete combiner implementation that is able to construct an override combination.
An override combination means that nodes in the first node structure take precedence over nodes in the
second, or - in other words - nodes of the second structure are only added to the resulting structure if they do not
occur in the first one. This is especially suitable for dealing with the properties of configurations that are
defined in an override
section of a configuration definition file (hence the name).
This combiner will iterate over the second node hierarchy and find all nodes that are not contained in the first
hierarchy; these are added to the result. If a node can be found in both structures, it is checked whether a
combination (in a recursive way) can be constructed for the two, which will then be added. Per default, nodes are
combined, which occur only once in both structures. This test is implemented in the canCombine()
method.
As is true for the UnionCombiner
, for this combiner list nodes are important. The addListNode()
can
be called to declare certain nodes as list nodes. This has the effect that these nodes will never be combined.
HANDLER
Constructor and Description |
---|
OverrideCombiner() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAttributes(ImmutableNode.Builder result,
ImmutableNode node1,
ImmutableNode node2)
Handles the attributes during a combination process.
|
protected ImmutableNode |
canCombine(ImmutableNode node1,
ImmutableNode node2,
ImmutableNode child)
Tests if a child node of the second node can be combined with the given child node of the first node.
|
ImmutableNode |
combine(ImmutableNode node1,
ImmutableNode node2)
Constructs an override combination for the passed in node structures.
|
addListNode, getListNodes, isListNode
public OverrideCombiner()
public ImmutableNode combine(ImmutableNode node1, ImmutableNode node2)
combine
in class NodeCombiner
node1
- the first nodenode2
- the second nodeprotected void addAttributes(ImmutableNode.Builder result, ImmutableNode node1, ImmutableNode node2)
result
- the resulting nodenode1
- the first nodenode2
- the second nodeprotected ImmutableNode canCombine(ImmutableNode node1, ImmutableNode node2, ImmutableNode child)
node1
- the first nodenode2
- the second nodechild
- the child node (of the first node)Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.