|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Node
Represents a part of an object. It could be the object itself, one of its properties, an item in a collection or a map entry. A node may have one parent node and any number of children. It also provides methods to read and write the property represented by this node on any object of the same type as the original object. Last but not least, a node knows how the associated property has changed compared to the base object.
Nested Class Summary | |
---|---|
static class |
Node.State
The state of a Node representing the difference between two objects. |
static interface |
Node.Visitor
Visitor to traverse a node graph. |
Field Summary | |
---|---|
static Node |
ROOT
|
Method Summary | |
---|---|
boolean |
addChild(Node node)
Adds a child to this node and sets this node as its parent node. |
Node |
getChild(Element pathElement)
Retrieve a child that matches the given path element relative to this node. |
Node |
getChild(PropertyPath path)
Retrieve a child that matches the given absolute path, starting from the current node. |
Node |
getChild(String propertyName)
Retrieve a child with the given property name relative to this node. |
Collection<Node> |
getChildren()
|
Node |
getParentNode()
|
PropertyPath |
getPropertyPath()
|
Node.State |
getState()
|
Class<?> |
getType()
|
boolean |
hasChanges()
|
boolean |
hasChildren()
|
boolean |
isAdded()
Convenience method for
|
boolean |
isChanged()
Convenience method for
|
boolean |
isCircular()
Convenience method for
|
boolean |
isCollectionNode()
|
boolean |
isIgnored()
Convenience method for
|
boolean |
isMapNode()
|
boolean |
isRemoved()
Convenience method for
|
boolean |
isRootNode()
|
boolean |
isUntouched()
Convenience method for
|
boolean |
matches(PropertyPath path)
|
void |
setParentNode(Node parent)
Sets the parent node. |
void |
setState(Node.State state)
|
void |
setType(Class<?> aClass)
Allows for explicit type definition. |
CollectionNode |
toCollectionNode()
|
MapNode |
toMapNode()
|
void |
visit(Node.Visitor visitor)
Visit this and all child nodes. |
void |
visitChildren(Node.Visitor visitor)
Visit all child nodes but not this one. |
Methods inherited from interface de.danielbechler.diff.accessor.CanonicalAccessor |
---|
canonicalGet, canonicalSet, canonicalUnset |
Methods inherited from interface de.danielbechler.diff.accessor.Accessor |
---|
get, set, unset |
Methods inherited from interface de.danielbechler.diff.accessor.PropertyDescriptor |
---|
getCategories, getPathElement, isEqualsOnly |
Field Detail |
---|
static final Node ROOT
Method Detail |
---|
Node getParentNode()
void setParentNode(Node parent)
parent
- The parent of this node. May be null, if this is a root node.Node.State getState()
void setState(Node.State state)
state
- The state of this node.boolean matches(PropertyPath path)
boolean isRootNode()
boolean hasChanges()
boolean isAdded()
getState()
== Node.State.ADDED
boolean isChanged()
getState()
== Node.State.CHANGED
boolean isRemoved()
getState()
== Node.State.REMOVED
boolean isUntouched()
getState()
== Node.State.UNTOUCHED
boolean isIgnored()
getState()
== Node.State.IGNORED
isIgnored
in interface PropertyDescriptor
boolean isCircular()
getState()
== Node.State.CIRCULAR
boolean isCollectionNode()
CollectionNode toCollectionNode()
boolean isMapNode()
MapNode toMapNode()
Class<?> getType()
void setType(Class<?> aClass)
getType()
will always
return the type returned by the accessor.
aClass
- The type of the value represented by this node.PropertyPath getPropertyPath()
boolean hasChildren()
true
if this node has children.Collection<Node> getChildren()
Node getChild(String propertyName)
propertyName
- The name of the property represented by the child node.
null
.Node getChild(PropertyPath path)
path
- The path from the object root to the requested child node.
null
.Node getChild(Element pathElement)
pathElement
- The path element of the childe node to get.
null
.boolean addChild(Node node)
node
- The node to add.void visit(Node.Visitor visitor)
visitor
- The visitor to use.void visitChildren(Node.Visitor visitor)
visitor
- The visitor to use.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |