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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDecoratedNodeState(@NotNull NodeState delegate, boolean useNativeEquals)
-
Method Summary
All Methods Static Methods Instance Methods Abstract 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.protected abstract @NotNull NodeState
decorateChild(@NotNull String name, @NotNull NodeState delegateChild)
protected abstract @Nullable PropertyState
decorateProperty(@NotNull PropertyState delegatePropertyState)
boolean
equals(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.protected static PropertyState
fixChildOrderPropertyState(NodeState nodeState, PropertyState propertyState)
Convenience method to help implementations that hide nodes set the :childOrder (OAK_CHILD_ORDER) property to its correct value.@NotNull NodeState
getChildNode(@NotNull String name)
Returns the named, possibly non-existent, child node.@NotNull Iterable<? extends ChildNodeEntry>
getChildNodeEntries()
Returns the iterable child node entries of this instance.NodeState
getDelegate()
protected @NotNull Iterable<PropertyState>
getNewPropertyStates()
@NotNull Iterable<? extends PropertyState>
getProperties()
Returns an iterable of the properties of this node.@Nullable PropertyState
getProperty(@NotNull String name)
Returns the named property, ornull
if no such property exists.boolean
hasChildNode(@NotNull String name)
Checks whether the named child node exists.protected boolean
hideChild(@NotNull String name, @NotNull NodeState delegateChild)
protected boolean
hideProperty(@NotNull String name)
-
Methods inherited from class org.apache.jackrabbit.oak.spi.state.AbstractNodeState
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, count, equals, getBoolean, getBoolean, getChildNodeCount, getChildNodeNames, getLong, getLong, getName, getName, getNames, getNames, getPropertyCount, getString, getString, getStrings, getStrings, hashCode, hasProperty, isValidName, toString, toString
-
-
-
-
Field Detail
-
delegate
protected final NodeState delegate
-
-
Constructor Detail
-
AbstractDecoratedNodeState
protected AbstractDecoratedNodeState(@NotNull @NotNull NodeState delegate, boolean useNativeEquals)
-
-
Method Detail
-
getDelegate
public NodeState getDelegate()
-
hideChild
protected boolean hideChild(@NotNull @NotNull String name, @NotNull @NotNull NodeState delegateChild)
-
decorateChild
@NotNull protected abstract @NotNull NodeState decorateChild(@NotNull @NotNull String name, @NotNull @NotNull NodeState delegateChild)
-
hideProperty
protected boolean hideProperty(@NotNull @NotNull String name)
-
getNewPropertyStates
@NotNull protected @NotNull Iterable<PropertyState> getNewPropertyStates()
-
decorateProperty
@Nullable protected abstract @Nullable PropertyState decorateProperty(@NotNull @NotNull PropertyState delegatePropertyState)
-
fixChildOrderPropertyState
protected static PropertyState fixChildOrderPropertyState(NodeState nodeState, PropertyState propertyState)
Convenience method to help implementations that hide nodes set the :childOrder (OAK_CHILD_ORDER) property to its correct value.
Intended to be used to implementdecorateProperty(PropertyState)
.- Parameters:
nodeState
- The current node state.propertyState
- The property that chould be checked.- Returns:
- The original propertyState, unless the property is called
:childOrder
.
-
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 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 String name) throws 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:
IllegalArgumentException
- if the given name string is is empty or contains a forward slash character
-
getChildNodeEntries
@NotNull public @NotNull 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 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 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(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)
-
-