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

java.lang.Object
  extended by org.rhq.helpers.perftest.support.jpa.EntityDependencyGraph

public class EntityDependencyGraph
extends Object

Produces a graph of Nodes linked to each other by Edges. Each Node corresponds to a single JPA entity and each Edge between them corresponds to a single relationship between the JPA entities (i.e. one of OneToOne, OneToMany, ManyToOne or ManyToMany).

Author:
Lukas Krejci

Constructor Summary
EntityDependencyGraph()
           
 
Method Summary
 Set<Node> addEntities(Class<?>... entities)
          A convenience method to add a number of entities to the graph at once.
 Set<Node> addEntities(Collection<Class<?>> entities)
          A convenience method to add a number of entities to the graph at once.
 Node addEntity(Class<?> entity)
          Adds a single entity to the dependency graph and analyzes it.
 Set<Node> getAllNodes()
           
 Set<Node> getLeafNodes()
           
 Node getNode(Class<?> entityClass)
           
 Set<Node> getRootNodes()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityDependencyGraph

public EntityDependencyGraph()
Method Detail

addEntity

public Node addEntity(Class<?> entity)
Adds a single entity to the dependency graph and analyzes it. This will cause all the dependent and depending entities to be included in the graph as well.

Parameters:
entity -
Returns:
the Node instance corresponding to the provided entity class or null if the class doesn't represent a JPA entity.

addEntities

public Set<Node> addEntities(Class<?>... entities)
A convenience method to add a number of entities to the graph at once.

Parameters:
entities -
Returns:
the set of nodes corresponding to the provided entities.

addEntities

public Set<Node> addEntities(Collection<Class<?>> entities)
A convenience method to add a number of entities to the graph at once.

Parameters:
entities -
Returns:
the set of nodes corresponding to the provided entities.

getAllNodes

public Set<Node> getAllNodes()
Returns:
all the nodes in the dependency graph

getNode

public Node getNode(Class<?> entityClass)
Parameters:
entityClass - the class of an entity
Returns:
the node from the dependency graph corresponding to the given class or null if such node is not present.

getRootNodes

public Set<Node> getRootNodes()
Returns:
all the nodes from the dependency graph with no parents (i.e. with no edges leading to them).

getLeafNodes

public Set<Node> getLeafNodes()
Returns:
all the nodes from the dependency graph with no children (i.e. no edges leading from them).

toString

public String toString()
Overrides:
toString in class Object


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