public class ModifiedNodeState extends AbstractNodeState
| Modifier and Type | Method and Description |
|---|---|
@NotNull NodeBuilder |
builder()
Returns a builder for constructing a new node state based on
this state, i.e.
|
boolean |
compareAgainstBaseState(NodeState base,
NodeStateDiff diff)
Since we keep track of an explicit base node state for a
ModifiedNodeState instance, we can do this in two steps:
first compare all the modified properties and child nodes to those
of the given base state, and then compare the base states to each
other, ignoring all changed properties and child nodes that were
already covered earlier. |
boolean |
exists()
Checks whether this node exists.
|
@NotNull NodeState |
getBaseState() |
@NotNull NodeState |
getChildNode(@NotNull java.lang.String name)
Returns the named, possibly non-existent, child node.
|
long |
getChildNodeCount(long max)
Returns the number of iterable child nodes of this node.
|
@NotNull java.lang.Iterable<? extends ChildNodeEntry> |
getChildNodeEntries()
Returns the iterable child node entries of this instance.
|
java.lang.Iterable<java.lang.String> |
getChildNodeNames()
Returns the names of all iterable child nodes.
|
@NotNull java.lang.Iterable<? extends PropertyState> |
getProperties()
Returns an iterable of the properties of this node.
|
PropertyState |
getProperty(@NotNull java.lang.String name)
Returns the named property, or
null if no such property exists. |
long |
getPropertyCount()
Returns the number of properties of this node.
|
boolean |
hasChildNode(@NotNull java.lang.String name)
Checks whether the named child node exists.
|
boolean |
hasProperty(@NotNull java.lang.String name)
Checks whether the named property exists.
|
static NodeState |
squeeze(NodeState state)
"Squeezes"
ModifiedNodeState instances into equivalent
MemoryNodeStates. |
checkValidName, compareAgainstBaseState, comparePropertiesAgainstBaseState, equals, equals, getBoolean, getBoolean, getLong, getLong, getName, getName, getNames, getNames, getString, getString, getStrings, getStrings, hashCode, isValidName, toString, toStringpublic static NodeState squeeze(NodeState state)
ModifiedNodeState instances into equivalent
MemoryNodeStates. Other kinds of states are returned as-is.@NotNull public @NotNull NodeState getBaseState()
@NotNull public @NotNull NodeBuilder builder()
NodeStatepublic boolean exists()
NodeStatetrue if this node exists, false if notpublic long getPropertyCount()
NodeStategetPropertyCount in interface NodeStategetPropertyCount in class AbstractNodeStatepublic boolean hasProperty(@NotNull
@NotNull java.lang.String name)
NodeStategetProperty(name) != null, but may be optimized
to avoid having to load the property value.hasProperty in interface NodeStatehasProperty in class AbstractNodeStatename - property nametrue if the named property exists,
false otherwisepublic PropertyState getProperty(@NotNull @NotNull java.lang.String name)
NodeStatenull if no such property exists.getProperty in interface NodeStategetProperty in class AbstractNodeStatename - name of the property to returnnull if not found@NotNull public @NotNull java.lang.Iterable<? extends PropertyState> getProperties()
NodeStatepublic long getChildNodeCount(long max)
NodeStateIf an implementation knows the exact value, it returns it (even if the value is higher than max). If the implementation does not know the exact value, and the child node count is higher than max, it may return Long.MAX_VALUE. The cost of the operation is at most O(max).
getChildNodeCount in interface NodeStategetChildNodeCount in class AbstractNodeStatemax - the maximum number of entries to traversepublic boolean hasChildNode(@NotNull
@NotNull java.lang.String name)
NodeStategetChildNode(name).exists(), except that
passing an invalid name as argument will result in a false
return value instead of an IllegalArgumentException.name - name of the child nodetrue if the named child node exists,
false otherwise@NotNull public @NotNull NodeState getChildNode(@NotNull @NotNull java.lang.String name)
NodeStateNodeState.exists() method on the returned child node to determine
whether the node exists or not.name - name of the child node to returnpublic java.lang.Iterable<java.lang.String> getChildNodeNames()
NodeStategetChildNodeNames in interface NodeStategetChildNodeNames in class AbstractNodeState@NotNull public @NotNull java.lang.Iterable<? extends ChildNodeEntry> getChildNodeEntries()
NodeState
Note on cost and performance: while it is possible to iterate over
all child NodeStates with the two methods NodeState.getChildNodeNames() and NodeState.getChildNode(String), this method is
considered more efficient because an implementation can potentially
perform the retrieval of the name and NodeState in one call.
This results in O(n) vs. O(n log n) when iterating over the child node
names and then look up the NodeState by name.
public boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff)
ModifiedNodeState instance, we can do this in two steps:
first compare all the modified properties and child nodes to those
of the given base state, and then compare the base states to each
other, ignoring all changed properties and child nodes that were
already covered earlier.compareAgainstBaseState in interface NodeStatecompareAgainstBaseState in class AbstractNodeStatebase - base statediff - handler of node state differencestrue if the full diff was performed, or
false if it was aborted as requested by the handler
(see the NodeStateDiff contract for more details)Copyright © 2010 - 2023 Adobe. All Rights Reserved