|
1 |
| package com.agical.rdoc.core.model.test; |
|
2 |
| |
|
3 |
| import java.io.Serializable; |
|
4 |
| import java.util.ArrayList; |
|
5 |
| import java.util.Iterator; |
|
6 |
| import java.util.List; |
|
7 |
| |
|
8 |
| |
|
9 |
| public abstract class AbstractCompositeTestNode implements TestNode, Serializable{ |
|
10 |
| |
|
11 |
| private List children = new ArrayList(); |
|
12 |
| |
|
13 |
384
| protected void addChild(TestNode node) {
|
|
14 |
384
| children.add( node );
|
|
15 |
| } |
|
16 |
| |
|
17 |
33
| public void accept(TestNodeVisitor visitor) {
|
|
18 |
33
| visitThis( visitor );
|
|
19 |
33
| visitChildren(visitor);
|
|
20 |
| } |
|
21 |
| |
|
22 |
| protected abstract void visitThis(TestNodeVisitor visitor); |
|
23 |
| |
|
24 |
33
| protected void visitChildren(TestNodeVisitor visitor) {
|
|
25 |
33
| for (Iterator iter = children.iterator(); iter.hasNext();) {
|
|
26 |
32
| TestNode testNode = (TestNode) iter.next();
|
|
27 |
32
| testNode.accept( visitor );
|
|
28 |
| } |
|
29 |
| } |
|
30 |
| |
|
31 |
13
| public boolean equals(Object obj) {
|
|
32 |
13
| return children.equals(((AbstractCompositeTestNode)obj).children);
|
|
33 |
| } |
|
34 |
| |
|
35 |
31
| public TestNode[] getChildren() {
|
|
36 |
31
| return (TestNode[])children.toArray(new TestNode[children.size()]);
|
|
37 |
| } |
|
38 |
| } |