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 parentNode,
Accessor accessor) |
DiffNode(DiffNode parentNode,
Accessor accessor,
Class<?> valueType) |
Modifier and Type | Method and Description |
---|---|
void |
addCategories(Collection<String> additionalCategories) |
void |
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 elementSelector)
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() |
<T extends Annotation> |
getFieldAnnotation(Class<T> annotationClass) |
Set<Annotation> |
getFieldAnnotations()
If this node represents a bean property this method returns all annotations of its field.
|
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() |
TypeInfo |
getValueTypeInfo() |
boolean |
hasChanges() |
boolean |
hasChildren() |
int |
hashCode() |
boolean |
isAdded()
Convenience method for
|
boolean |
isChanged()
Convenience method for
|
boolean |
isCircular()
Convenience method for
|
boolean |
isExcluded()
Deprecated.
This method was a shortcut to extract the "exclude" flag from the ObjectDiffProperty
annotation. Since we found a better way to do that, it is not needed anymore and will be removed in future
versions. The name is also misleading. It implies that here lies the truth about the exclusion, but only the
InclusionService can tell for sure. This flag is just only little piece of the puzzle.
|
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) |
static DiffNode |
newRootNode() |
static DiffNode |
newRootNodeWithType(Class<?> valueType) |
void |
set(Object target,
Object value) |
void |
setChildIdentityStrategy(IdentityStrategy identityStrategy) |
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 to explicity set the type of this node.
|
void |
setValueTypeInfo(TypeInfo typeInfo) |
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 void setChildIdentityStrategy(IdentityStrategy identityStrategy)
public static DiffNode newRootNode()
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 NodePath getPath()
public ElementSelector getElementSelector()
public Class<?> getValueType()
public final void setType(Class<?> aClass)
aClass
- The type of the value represented by this node.public TypeInfo getValueTypeInfo()
public void setValueTypeInfo(TypeInfo typeInfo)
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 elementSelector)
elementSelector
- 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 void 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> getFieldAnnotations()
public <T extends Annotation> T getFieldAnnotation(Class<T> annotationClass)
T
- annotationClass
- the annotation we are looking forpublic 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
@Deprecated public boolean isExcluded()
TypePropertyAnnotationInclusionResolver
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 void addCategories(Collection<String> additionalCategories)
public NodePath getCircleStartPath()
isCircular()
returns true
.public void setCircleStartPath(NodePath circularStartPath)
public DiffNode getCircleStartNode()
public void setCircleStartNode(DiffNode circleStartNode)
Copyright © 2016. All rights reserved.