Class ApplyDiff
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.state.ApplyDiff
-
- All Implemented Interfaces:
NodeStateDiff
public class ApplyDiff extends java.lang.Object implements NodeStateDiff
A node state diff handler that applies all reported changes as-is to the given node builder. No conflict detection or resolution is attempted. The main use case for this class is to call all theNodeBuilder
methods necessary to go from a given base state to any given target state.The expected usage pattern looks like this:
NodeState base = ...; NodeState target = ...; NodeBuilder builder = base.builder(); target.compareAgainstBaseState(base, new ApplyDiff(builder)); assertEquals(target, builder.getNodeState());
Alternatively, the
apply(NodeState)
method can be used to set the content of a given builder:NodeBuilder builder = ...; NodeState target = ...; new ApplyDiff(builder).apply(target); assertEquals(target, builder.getNodeState());
-
-
Constructor Summary
Constructors Constructor Description ApplyDiff(NodeBuilder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(NodeState target)
boolean
childNodeAdded(java.lang.String name, NodeState after)
Called for all added child nodes.boolean
childNodeChanged(java.lang.String name, NodeState before, NodeState after)
Called for all child nodes that may contain changes between the before and after states.boolean
childNodeDeleted(java.lang.String name, NodeState before)
Called for all deleted child nodes.boolean
propertyAdded(PropertyState after)
Called for all added properties.boolean
propertyChanged(PropertyState before, PropertyState after)
Called for all changed properties.boolean
propertyDeleted(PropertyState before)
Called for all deleted properties.
-
-
-
Constructor Detail
-
ApplyDiff
public ApplyDiff(NodeBuilder builder)
-
-
Method Detail
-
apply
public void apply(NodeState target)
-
propertyAdded
public boolean propertyAdded(PropertyState after)
Description copied from interface:NodeStateDiff
Called for all added properties.- Specified by:
propertyAdded
in interfaceNodeStateDiff
- Parameters:
after
- property state after the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
propertyChanged
public boolean propertyChanged(PropertyState before, PropertyState after)
Description copied from interface:NodeStateDiff
Called for all changed properties. The names of the given two property states are guaranteed to be the same.- Specified by:
propertyChanged
in interfaceNodeStateDiff
- Parameters:
before
- property state before the changeafter
- property state after the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
propertyDeleted
public boolean propertyDeleted(PropertyState before)
Description copied from interface:NodeStateDiff
Called for all deleted properties.- Specified by:
propertyDeleted
in interfaceNodeStateDiff
- Parameters:
before
- property state before the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
childNodeAdded
public boolean childNodeAdded(java.lang.String name, NodeState after)
Description copied from interface:NodeStateDiff
Called for all added child nodes.- Specified by:
childNodeAdded
in interfaceNodeStateDiff
- Parameters:
name
- name of the added child nodeafter
- child node state after the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
childNodeChanged
public boolean childNodeChanged(java.lang.String name, NodeState before, NodeState after)
Description copied from interface:NodeStateDiff
Called for all child nodes that may contain changes between the before and after states. The comparison implementation is expected to make an effort to avoid calling this method on child nodes under which nothing has changed.- Specified by:
childNodeChanged
in interfaceNodeStateDiff
- Parameters:
name
- name of the changed child nodebefore
- child node state before the changeafter
- child node state after the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
childNodeDeleted
public boolean childNodeDeleted(java.lang.String name, NodeState before)
Description copied from interface:NodeStateDiff
Called for all deleted child nodes.- Specified by:
childNodeDeleted
in interfaceNodeStateDiff
- Parameters:
name
- name of the deleted child nodebefore
- child node state before the change- Returns:
true
to continue the comparison,false
to abort. Abort will stop comparing completely, that means sibling nodes and sibling nodes of all parents are not further compared.
-
-