Class AbstractDecoratedNodeState
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.state.AbstractNodeState
-
- org.apache.jackrabbit.oak.plugins.migration.AbstractDecoratedNodeState
-
- All Implemented Interfaces:
NodeState
- Direct Known Subclasses:
FilteringNodeState
,ReportingNodeState
public abstract class AbstractDecoratedNodeState extends AbstractNodeState
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull NodeBuilder
builder()
The AbstractDecoratedNodeState implementation returns a ReadOnlyBuilder, which will fail for any mutable operation.boolean
compareAgainstBaseState(NodeState base, NodeStateDiff diff)
Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.boolean
equals(java.lang.Object other)
Note that any implementation-specific optimizations of wrapped NodeStates will not work if a AbstractDecoratedNodeState is passed into their#equals()
method.boolean
exists()
Checks whether this node exists.@NotNull NodeState
getChildNode(@NotNull java.lang.String name)
Returns the named, possibly non-existent, child node.@NotNull java.lang.Iterable<? extends ChildNodeEntry>
getChildNodeEntries()
Returns the iterable child node entries of this instance.NodeState
getDelegate()
@NotNull java.lang.Iterable<? extends PropertyState>
getProperties()
Returns an iterable of the properties of this node.@Nullable PropertyState
getProperty(@NotNull java.lang.String name)
Returns the named property, ornull
if no such property exists.boolean
hasChildNode(@NotNull java.lang.String name)
Checks whether the named child node exists.-
Methods inherited from class org.apache.jackrabbit.oak.spi.state.AbstractNodeState
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, equals, getBoolean, getBoolean, getChildNodeCount, getChildNodeNames, getLong, getLong, getName, getName, getNames, getNames, getPropertyCount, getString, getString, getStrings, getStrings, hashCode, hasProperty, isValidName, toString, toString
-
-
-
-
Method Detail
-
getDelegate
public NodeState getDelegate()
-
builder
@NotNull public @NotNull NodeBuilder builder()
The AbstractDecoratedNodeState implementation returns a ReadOnlyBuilder, which will fail for any mutable operation. This method can be overridden to return a different NodeBuilder implementation.- Returns:
- a NodeBuilder instance corresponding to this NodeState.
-
exists
public boolean exists()
Description copied from interface:NodeState
Checks whether this node exists. See the above discussion about the existence of node states.- Returns:
true
if this node exists,false
if not
-
hasChildNode
public boolean hasChildNode(@NotNull @NotNull java.lang.String name)
Description copied from interface:NodeState
Checks whether the named child node exists. The implementation is equivalent togetChildNode(name).exists()
, except that passing an invalid name as argument will result in afalse
return value instead of anIllegalArgumentException
.- Parameters:
name
- name of the child node- Returns:
true
if the named child node exists,false
otherwise
-
getChildNode
@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name) throws java.lang.IllegalArgumentException
Description copied from interface:NodeState
Returns the named, possibly non-existent, child node. Use theNodeState.exists()
method on the returned child node to determine whether the node exists or not.- Parameters:
name
- name of the child node to return- Returns:
- named child node
- Throws:
java.lang.IllegalArgumentException
- if the given name string is is empty or contains a forward slash character
-
getChildNodeEntries
@NotNull public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
Description copied from interface:NodeState
Returns the iterable child node entries of this instance. Multiple iterations are guaranteed to return the child nodes in the same order, but the specific order used is implementation dependent and may change across different states of the same node.Note on cost and performance: while it is possible to iterate over all child
NodeState
s with the two methodsNodeState.getChildNodeNames()
andNodeState.getChildNode(String)
, this method is considered more efficient because an implementation can potentially perform the retrieval of the name andNodeState
in one call. This results in O(n) vs. O(n log n) when iterating over the child node names and then look up theNodeState
by name.- Returns:
- child node entries in some stable order
-
getProperty
@Nullable public @Nullable PropertyState getProperty(@NotNull @NotNull java.lang.String name)
Description copied from interface:NodeState
Returns the named property, ornull
if no such property exists.- Specified by:
getProperty
in interfaceNodeState
- Overrides:
getProperty
in classAbstractNodeState
- Parameters:
name
- name of the property to return- Returns:
- named property, or
null
if not found
-
getProperties
@NotNull public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
Description copied from interface:NodeState
Returns an iterable of the properties of this node. Multiple iterations are guaranteed to return the properties in the same order, but the specific order used is implementation-dependent and may change across different states of the same node.- Returns:
- properties in some stable order
-
equals
public boolean equals(java.lang.Object other)
Note that any implementation-specific optimizations of wrapped NodeStates will not work if a AbstractDecoratedNodeState is passed into their#equals()
method. This implementation will compare the wrapped NodeState, however. So optimizations work when calling#equals()
on a ReportingNodeState.- Overrides:
equals
in classAbstractNodeState
- Parameters:
other
- Object to compare with this NodeState.- Returns:
- true if the given object is equal to this NodeState, false otherwise.
-
compareAgainstBaseState
public boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff)
Description copied from class:AbstractNodeState
Generic default comparison algorithm that simply walks through the property and child node lists of the given base state and compares the entries one by one with corresponding ones (if any) in this state.- Specified by:
compareAgainstBaseState
in interfaceNodeState
- Overrides:
compareAgainstBaseState
in classAbstractNodeState
- Parameters:
base
- base statediff
- handler of node state differences- Returns:
true
if the full diff was performed, orfalse
if it was aborted as requested by the handler (see theNodeStateDiff
contract for more details)
-
-