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 NodeBuilderbuilder()The AbstractDecoratedNodeState implementation returns a ReadOnlyBuilder, which will fail for any mutable operation.booleancompareAgainstBaseState(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.booleanequals(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.booleanexists()Checks whether this node exists.@NotNull NodeStategetChildNode(@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.NodeStategetDelegate()@NotNull java.lang.Iterable<? extends PropertyState>getProperties()Returns an iterable of the properties of this node.@Nullable PropertyStategetProperty(@NotNull java.lang.String name)Returns the named property, ornullif no such property exists.booleanhasChildNode(@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:NodeStateChecks whether this node exists. See the above discussion about the existence of node states.- Returns:
trueif this node exists,falseif not
-
hasChildNode
public boolean hasChildNode(@NotNull @NotNull java.lang.String name)Description copied from interface:NodeStateChecks whether the named child node exists. The implementation is equivalent togetChildNode(name).exists(), except that passing an invalid name as argument will result in afalsereturn value instead of anIllegalArgumentException.- Parameters:
name- name of the child node- Returns:
trueif the named child node exists,falseotherwise
-
getChildNode
@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name) throws java.lang.IllegalArgumentException
Description copied from interface:NodeStateReturns 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:NodeStateReturns 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
NodeStates 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 andNodeStatein one call. This results in O(n) vs. O(n log n) when iterating over the child node names and then look up theNodeStateby 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:NodeStateReturns the named property, ornullif no such property exists.- Specified by:
getPropertyin interfaceNodeState- Overrides:
getPropertyin classAbstractNodeState- Parameters:
name- name of the property to return- Returns:
- named property, or
nullif not found
-
getProperties
@NotNull public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
Description copied from interface:NodeStateReturns 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:
equalsin 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:AbstractNodeStateGeneric 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:
compareAgainstBaseStatein interfaceNodeState- Overrides:
compareAgainstBaseStatein classAbstractNodeState- Parameters:
base- base statediff- handler of node state differences- Returns:
trueif the full diff was performed, orfalseif it was aborted as requested by the handler (see theNodeStateDiffcontract for more details)
-
-