public abstract class AbstractNodeState extends java.lang.Object implements NodeState
NodeState implementations.
This base class contains default implementations of the
equals(Object) and hashCode() methods based on
the implemented interface.
This class also implements trivial (and potentially very slow) versions of
the getProperty(String) and getPropertyCount() methods
based on NodeState.getProperties(). The getChildNodeCount(long) method
is similarly implemented based on NodeState.getChildNodeEntries().
Subclasses should normally override these method with a more efficient
alternatives.
| Constructor and Description |
|---|
AbstractNodeState() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkValidName(java.lang.String name) |
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.
|
static boolean |
compareAgainstBaseState(NodeState state,
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.
|
static boolean |
comparePropertiesAgainstBaseState(NodeState state,
NodeState base,
NodeStateDiff diff)
Compares the properties of
base state with this
state. |
static boolean |
equals(NodeState a,
NodeState b) |
boolean |
equals(java.lang.Object that)
Checks whether the given object is equal to this one.
|
static boolean |
getBoolean(NodeState state,
java.lang.String name) |
boolean |
getBoolean(@NotNull java.lang.String name)
Returns the boolean value of the named property.
|
long |
getChildNodeCount(long max)
Returns the number of iterable child nodes of this node.
|
java.lang.Iterable<java.lang.String> |
getChildNodeNames()
Returns the names of all iterable child nodes.
|
static long |
getLong(NodeState state,
java.lang.String name) |
long |
getLong(java.lang.String name)
Returns the long value of the named property.
|
static java.lang.String |
getName(NodeState state,
java.lang.String name) |
@Nullable java.lang.String |
getName(@NotNull java.lang.String name)
Returns the name value of the named property.
|
static java.lang.Iterable<java.lang.String> |
getNames(NodeState state,
java.lang.String name) |
@NotNull java.lang.Iterable<java.lang.String> |
getNames(@NotNull java.lang.String name)
Returns the name values of the named property.
|
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.
|
static java.lang.String |
getString(NodeState state,
java.lang.String name) |
java.lang.String |
getString(java.lang.String name)
Returns the string value of the named property.
|
static java.lang.Iterable<java.lang.String> |
getStrings(NodeState state,
java.lang.String name) |
@NotNull java.lang.Iterable<java.lang.String> |
getStrings(@NotNull java.lang.String name)
Returns the string values of the named property.
|
int |
hashCode()
Returns a hash code that's compatible with how the
equals(Object) method is implemented. |
boolean |
hasProperty(@NotNull java.lang.String name)
Checks whether the named property exists.
|
static boolean |
isValidName(java.lang.String name) |
java.lang.String |
toString()
Returns a string representation of this node state.
|
static java.lang.String |
toString(NodeState state) |
builder, exists, getChildNode, getChildNodeEntries, getProperties, hasChildNodepublic static boolean isValidName(java.lang.String name)
public static void checkValidName(java.lang.String name)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic static boolean getBoolean(NodeState state, java.lang.String name)
public static long getLong(NodeState state, java.lang.String name)
public static java.lang.String getString(NodeState state, java.lang.String name)
public static java.lang.Iterable<java.lang.String> getStrings(NodeState state, java.lang.String name)
public static java.lang.String getName(NodeState state, java.lang.String name)
public static java.lang.Iterable<java.lang.String> getNames(NodeState state, java.lang.String name)
public static boolean compareAgainstBaseState(NodeState state, NodeState base, NodeStateDiff diff)
public static boolean comparePropertiesAgainstBaseState(NodeState state, NodeState base, NodeStateDiff diff)
base state with this
state.state - the head node state.base - the base node state.diff - the node state diff.true to continue the comparison, false to stoppublic static java.lang.String toString(NodeState state)
public 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 NodeStatename - property nametrue if the named property exists,
false otherwisepublic boolean getBoolean(@NotNull
@NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
return property != null
&& property.getType() == Type.BOOLEAN
&& property.getValue(Type.BOOLEAN);
getBoolean in interface NodeStatename - property namefalsepublic long getLong(java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.LONG) {
return property.getValue(Type.LONG);
} else {
return 0;
}
public java.lang.String getString(java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.STRING) {
return property.getValue(Type.STRING);
} else {
return null;
}
@NotNull
public @NotNull java.lang.Iterable<java.lang.String> getStrings(@NotNull
@NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.STRINGS) {
return property.getValue(Type.STRINGS);
} else {
return Collections.emptyList();
}
getStrings in interface NodeStatename - property name@Nullable
public @Nullable java.lang.String getName(@NotNull
@NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.NAME) {
return property.getValue(Type.NAME);
} else {
return null;
}
@NotNull
public @NotNull java.lang.Iterable<java.lang.String> getNames(@NotNull
@NotNull java.lang.String name)
NodeState
PropertyState property = state.getProperty(name);
if (property != null && property.getType() == Type.NAMES) {
return property.getValue(Type.NAMES);
} else {
return Collections.emptyList();
}
public PropertyState getProperty(@NotNull @NotNull java.lang.String name)
NodeStatenull if no such property exists.getProperty in interface NodeStatename - name of the property to returnnull if not foundpublic long getPropertyCount()
NodeStategetPropertyCount in interface 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 NodeStatemax - the maximum number of entries to traversepublic java.lang.Iterable<java.lang.String> getChildNodeNames()
NodeStategetChildNodeNames in interface NodeStatepublic boolean compareAgainstBaseState(NodeState base, NodeStateDiff diff)
compareAgainstBaseState in interface NodeStatebase - 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)public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object that)
equals in class java.lang.Objectthat - target of the comparisontrue if the objects are equal,
false otherwisepublic int hashCode()
equals(Object) method is implemented. The current
implementation simply returns zero for everything since
NodeState instances are not intended for use as hash keys.hashCode in class java.lang.ObjectCopyright © 2010 - 2023 Adobe. All Rights Reserved