Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Daniel Bechler
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package de.danielbechler.diff.node;
 
 
 import java.util.*;

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.

Author(s):
Daniel Bechler
 
 public interface Node extends CanonicalAccessor
 {
 	public static final Node ROOT = null;

Visitor to traverse a node graph.
 
 	public static interface Visitor
 	{
 		void accept(Node nodeVisit visit);
 	}

The state of a Node representing the difference between two objects.
 
 	public enum State
 	{
The value has been added to the working object.
 
 		ADDED,

The value has been changed compared to the base object.
 
 		CHANGED,

The value has been removed from the working object.
 
 		REMOVED,

The value is identical between working and base
 
 		UNTOUCHED,

Special state to mark circular references
 
 		CIRCULAR,

The value has not been looked at and has been ignored.
 
 		IGNORED
 	}

Returns:
The parent node, if any.
 
Sets the parent node.

Parameters:
parent The parent of this node. May be null, if this is a root node.
 
 	void setParentNode(Node parent);

Returns:
The state of this node.
 

Parameters:
state The state of this node.
 
 	void setState(State state);
 
 	boolean matches(PropertyPath path);
 
 	boolean isRootNode();
 
 	boolean hasChanges();

Convenience method for getState() == Node.State.ADDED
 
 	boolean isAdded();

Convenience method for getState() == Node.State.CHANGED
 
 	boolean isChanged();

Convenience method for getState() == Node.State.REMOVED
 
 	boolean isRemoved();

Convenience method for getState() == Node.State.UNTOUCHED
 
 	boolean isUntouched();

Convenience method for getState() == Node.State.IGNORED
	boolean isIgnored();

Convenience method for getState() == Node.State.CIRCULAR
	boolean isCircular();
	boolean isCollectionNode();
	boolean isMapNode();
	void setCircleStartPath(PropertyPath circularStartPath);

Returns:
Returns the path to the first node in the hierarchy that represents the same object instance as this one. (Only if isCircular() returns true.

Returns:
Returns the type of the property represented by this node, or null if unavailable.
	Class<?> getType();

Allows for explicit type definition. However, if the accessor is TypeAware, getType() will always return the type returned by the accessor.

Parameters:
aClass The type of the value represented by this node.
	void setType(Class<?> aClass);

Returns:
The absolute property path from the object root up to this node.

Returns:
true if this node has children.
	boolean hasChildren();

Returns:
The child nodes of this node.
Retrieve a child with the given property name relative to this node.

Parameters:
propertyName The name of the property represented by the child node.
Returns:
The requested child node or null.
	Node getChild(String propertyName);

Retrieve a child that matches the given absolute path, starting from the current node.

Parameters:
path The path from the object root to the requested child node.
Returns:
The requested child node or null.
Retrieve a child that matches the given path element relative to this node.

Parameters:
pathElement The path element of the child node to get.
Returns:
The requested child node or null.
	Node getChild(Element pathElement);

Adds a child to this node and sets this node as its parent node.

Parameters:
node The node to add.
	boolean addChild(Node node);

Visit this and all child nodes.

Parameters:
visitor The visitor to use.
	void visit(Visitor visitor);

Visit all child nodes but not this one.

Parameters:
visitor The visitor to use.
	void visitChildren(Visitor visitor);

If this node represents a bean property this method returns all annotations of its getter.

Returns:
A set of annotations of this nodes property getter or an empty set.
	<T extends Annotation> T getPropertyAnnotation(Class<T> annotationClass);
New to GrepCode? Check out our FAQ X