org.rhq.helpers.perftest.support.jpa
Class Node

java.lang.Object
  extended by org.rhq.helpers.perftest.support.jpa.Node
All Implemented Interfaces:
Comparable<Node>

public class Node
extends Object
implements Comparable<Node>

Represents a node in the entity dependency graph.

Author:
Lukas Krejci

Constructor Summary
Node(Class<?> entity)
           
 
Method Summary
 void addChild(Node child, Field childField, Field thisField, DependencyType dependencyType)
          Similar to addParent(Node, Field, Field, DependencyType) but creates an edge with this node being the "from" and the child node being the "to" of the newly created edge.
protected  void addEdge(Edge edge)
          This method is called from addParent(Node, Field, Field, DependencyType) and addChild(Node, Field, Field, DependencyType) methods to actually store an instance of an edge in this instance's edge set.
 void addParent(Node parent, Field parentField, Field thisField, DependencyType dependencyType)
          Add a parent node.
 int compareTo(Node o)
           
 boolean equals(Object other)
           
 SortedSet<Node> getChildren(boolean onlyExplicitRelations)
          Returns the children of this node.
 Set<Edge> getEdges()
           
 Class<?> getEntity()
          The class of the JPA entity this node represents.
 Set<Edge> getIncomingEdges()
           
 Set<Edge> getOutgoingEdges()
           
 SortedSet<Node> getParents(boolean onlyExplicitRelations)
          Return the parents of this node.
 SortedSet<Node> getTransitiveChildren(boolean onlyExplicitRelations)
          Returns this node, its children, their children, etc.
 SortedSet<Node> getTransitiveParents(boolean onlyExplicitRelations)
          Returns this node, its parents, their parents, etc, recursively up the dependency graph.
 EntityTranslation getTranslation()
           
 int hashCode()
           
 void setTranslation(EntityTranslation translation)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(Class<?> entity)
Method Detail

getEntity

public Class<?> getEntity()
The class of the JPA entity this node represents.


getTranslation

public EntityTranslation getTranslation()
Returns:
the translation of this entity to the SQL terms.

setTranslation

public void setTranslation(EntityTranslation translation)

addParent

public void addParent(Node parent,
                      Field parentField,
                      Field thisField,
                      DependencyType dependencyType)
Add a parent node. This creates a new edge with the parent node set as the "from" node and this node as the "to" node. The edge instance is shared in both this' and parent's edge set.

Parameters:
parent - the parent node
parentField - the field on the parent node's entity that the edge is to be linked with
thisField - the field on this node's entity that the edge is to be linked with
dependencyType - the type of the JPA dependency

addChild

public void addChild(Node child,
                     Field childField,
                     Field thisField,
                     DependencyType dependencyType)
Similar to addParent(Node, Field, Field, DependencyType) but creates an edge with this node being the "from" and the child node being the "to" of the newly created edge.

Parameters:
child -
childField -
thisField -
dependencyType -

addEdge

protected void addEdge(Edge edge)
This method is called from addParent(Node, Field, Field, DependencyType) and addChild(Node, Field, Field, DependencyType) methods to actually store an instance of an edge in this instance's edge set.

Parameters:
edge -

getEdges

public Set<Edge> getEdges()
Returns:
all the edges leading from or to this node.

getOutgoingEdges

public Set<Edge> getOutgoingEdges()
Returns:
the edges going out of this node (i.e. edges leading to children of this node)

getIncomingEdges

public Set<Edge> getIncomingEdges()
Returns:
the edges coming to this node (i.e. edges leading from parents of this node)

getParents

public SortedSet<Node> getParents(boolean onlyExplicitRelations)
Return the parents of this node. When the onlyExplicitRelations is true, then only the edges that have and non-null "from" field are considered. This means that only parents that explicitly link to this entity are considered. A null from field means that the relation was only defined on the "to" side and that the parent entity has no explicit knowledge of the relationship.

Parameters:
onlyExplicitRelations -
Returns:

getChildren

public SortedSet<Node> getChildren(boolean onlyExplicitRelations)
Returns the children of this node. The onlyExplicitRelations argument has the same meaning as for the getParents(boolean) method.

Parameters:
onlyExplicitRelations -
Returns:

getTransitiveParents

public SortedSet<Node> getTransitiveParents(boolean onlyExplicitRelations)
Returns this node, its parents, their parents, etc, recursively up the dependency graph.

Parameters:
onlyExplicitRelations - the same meaning as for getParents(boolean)
Returns:

getTransitiveChildren

public SortedSet<Node> getTransitiveChildren(boolean onlyExplicitRelations)
Returns this node, its children, their children, etc. recursively.

Parameters:
onlyExplicitRelations - the same meaning as for getParents(boolean)
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

compareTo

public int compareTo(Node o)
Specified by:
compareTo in interface Comparable<Node>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.