| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| net.sf.tlc.ioc.impl.DependencyNode |
|
|
| 1 | /* |
|
| 2 | * Created on May 23, 2005 |
|
| 3 | * |
|
| 4 | * A node in a class dependency tree. |
|
| 5 | */ |
|
| 6 | package net.sf.tlc.ioc.impl; |
|
| 7 | ||
| 8 | import java.lang.reflect.Constructor; |
|
| 9 | import java.util.Hashtable; |
|
| 10 | import java.util.Iterator; |
|
| 11 | import java.util.Map; |
|
| 12 | ||
| 13 | /** |
|
| 14 | * A node in a class dependency tree. |
|
| 15 | * |
|
| 16 | * @author aisrael |
|
| 17 | */ |
|
| 18 | public final class DependencyNode { |
|
| 19 | ||
| 20 | private final Class clazz; |
|
| 21 | ||
| 22 | private final Map dependencies; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Construct a dependency tree node for the given class |
|
| 26 | * |
|
| 27 | * @param clazz |
|
| 28 | * Class |
|
| 29 | */ |
|
| 30 | 0 | public DependencyNode(final Class clazz) { |
| 31 | 0 | this.clazz = clazz; |
| 32 | 0 | this.dependencies = new Hashtable(clazz.getConstructors().length); |
| 33 | 0 | } |
| 34 | ||
| 35 | /** |
|
| 36 | * @return the class this dependency node represents |
|
| 37 | */ |
|
| 38 | public Class getClazz() { |
|
| 39 | 0 | return this.clazz; |
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Add a dependency from the parent class upon the given class. |
|
| 44 | * @param constructor Constructor |
|
| 45 | * @param deps DependencyNode[] |
|
| 46 | */ |
|
| 47 | public void addDependency(final Constructor constructor, class="keyword">final DependencyNode[] deps) { |
|
| 48 | 0 | this.dependencies.put(constructor, deps); |
| 49 | 0 | } |
| 50 | ||
| 51 | /** |
|
| 52 | * Return the dependencies for the given constructor of this class. |
|
| 53 | * |
|
| 54 | * @param constructor |
|
| 55 | * Constructor |
|
| 56 | * @return DependencyNode[] |
|
| 57 | */ |
|
| 58 | public DependencyNode[] getDependency(final Constructor constructor) { |
|
| 59 | 0 | return (DependencyNode[]) dependencies.get(constructor); |
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @return Iterator |
|
| 64 | */ |
|
| 65 | public Iterator iterator() { |
|
| 66 | 0 | return dependencies.keySet().iterator(); |
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * (non-Javadoc) |
|
| 71 | * @see java.lang.Object#toString() |
|
| 72 | */ |
|
| 73 | public String toString() { |
|
| 74 | 0 | return "(" + super.toString() + " (dependencyPaths " + dependencies.size() + "))"; |
| 75 | } |
|
| 76 | ||
| 77 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |