public class DiffNode extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DiffNode.State
The state of a
DiffNode representing the difference between two objects. |
static interface |
DiffNode.Visitor
Visitor to traverse a node graph.
|
Constructor and Description |
---|
DiffNode() |
DiffNode(Accessor accessor,
Class<?> valueType) |
DiffNode(Class<?> valueType) |
DiffNode(DiffNode parentNode,
Accessor accessor,
Class<?> valueType) |
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(DiffNode node)
Adds a child to this node and sets this node as its parent node.
|
Object |
canonicalGet(Object target) |
void |
canonicalSet(Object target,
Object value) |
void |
canonicalUnset(Object target) |
int |
childCount() |
boolean |
equals(Object o) |
Object |
get(Object target) |
Set<String> |
getCategories() |
DiffNode |
getChild(ElementSelector pathElementSelector)
Retrieve a child that matches the given path element relative to this node.
|
DiffNode |
getChild(List<ElementSelector> selectors)
Retrieve a child that matches the given path element relative to this node.
|
DiffNode |
getChild(NodePath nodePath)
Retrieve a child that matches the given absolute path, starting from the current node.
|
DiffNode |
getChild(String propertyName)
Retrieve a child with the given property name relative to this node.
|
DiffNode |
getCircleStartNode() |
NodePath |
getCircleStartPath() |
ElementSelector |
getElementSelector() |
DiffNode |
getParentNode() |
NodePath |
getPath() |
<T extends Annotation> |
getPropertyAnnotation(Class<T> annotationClass) |
Set<Annotation> |
getPropertyAnnotations()
If this node represents a bean property this method returns all annotations of its getter.
|
String |
getPropertyName()
If this node represents a bean property, this method will simply return its name.
|
DiffNode.State |
getState() |
Class<?> |
getValueType() |
boolean |
hasChanges() |
boolean |
hasChildren() |
int |
hashCode() |
boolean |
isAdded()
Convenience method for
|
boolean |
isChanged()
Convenience method for
|
boolean |
isCircular()
Convenience method for
|
boolean |
isExcluded() |
boolean |
isIgnored()
Convenience method for
|
boolean |
isPropertyAware()
Returns
true when this node represents a bean property and can therefore be queried for property
specific information like annotations or property types. |
boolean |
isRemoved()
Convenience method for
|
boolean |
isRootNode() |
boolean |
isUntouched()
Convenience method for
|
boolean |
matches(NodePath path) |
void |
set(Object target,
Object value) |
void |
setCircleStartNode(DiffNode circleStartNode) |
void |
setCircleStartPath(NodePath circularStartPath) |
protected void |
setParentNode(DiffNode parentNode)
Sets the parent node.
|
void |
setState(DiffNode.State state) |
void |
setType(Class<?> aClass)
Allows for explicit type definition.
|
String |
toString() |
void |
unset(Object target) |
void |
visit(DiffNode.Visitor visitor)
Visit this and all child nodes.
|
protected void |
visit(DiffNode.Visitor visitor,
Visit visit) |
void |
visitChildren(DiffNode.Visitor visitor)
Visit all child nodes but not this one.
|
void |
visitParents(DiffNode.Visitor visitor) |
public static final DiffNode ROOT
public DiffNode(Class<?> valueType)
public DiffNode()
public DiffNode.State getState()
public void setState(DiffNode.State state)
state
- The state of this node.public boolean matches(NodePath path)
public boolean hasChanges()
public final boolean isAdded()
getState()
== DiffNode.State.ADDED
public final boolean isChanged()
getState()
== DiffNode.State.CHANGED
public final boolean isRemoved()
getState()
== DiffNode.State.REMOVED
public final boolean isUntouched()
getState()
== DiffNode.State.UNTOUCHED
public boolean isCircular()
getState()
== DiffNode.State.CIRCULAR
public final NodePath getPath()
public ElementSelector getElementSelector()
public Class<?> getValueType()
public void setType(Class<?> aClass)
getValueType()
will
always return the type returned by the accessor.aClass
- The type of the value represented by this node.public boolean hasChildren()
true
if this node has children.public int childCount()
public DiffNode getChild(String propertyName)
propertyName
- The name of the property represented by the child node.null
.public DiffNode getChild(ElementSelector pathElementSelector)
pathElementSelector
- The path element of the child node to get.null
.public DiffNode getChild(NodePath nodePath)
nodePath
- The path from the object root to the requested child node.null
.public DiffNode getChild(List<ElementSelector> selectors)
selectors
- The path element of the child node to get.null
.public boolean addChild(DiffNode node)
node
- The node to add.public final void visit(DiffNode.Visitor visitor)
visitor
- The visitor to use.protected final void visit(DiffNode.Visitor visitor, Visit visit)
public final void visitChildren(DiffNode.Visitor visitor)
visitor
- The visitor to use.public final void visitParents(DiffNode.Visitor visitor)
public Set<Annotation> getPropertyAnnotations()
public <T extends Annotation> T getPropertyAnnotation(Class<T> annotationClass)
public String getPropertyName()
public final boolean isPropertyAware()
true
when this node represents a bean property and can therefore be queried for property
specific information like annotations or property types. But there will also be nodes that represent collection
items, map entries, etc. In those cases this method will return false
.public final boolean isRootNode()
public final boolean isIgnored()
getState()
== DiffNode.State.IGNORED
public boolean isExcluded()
public DiffNode getParentNode()
protected final void setParentNode(DiffNode parentNode)
parentNode
- The parent of this node. May be null, if this is a root node.public void unset(Object target)
public void canonicalUnset(Object target)
public NodePath getCircleStartPath()
isCircular()
returns true
.public void setCircleStartPath(NodePath circularStartPath)
public DiffNode getCircleStartNode()
public void setCircleStartNode(DiffNode circleStartNode)
Copyright © 2014. All rights reserved.