CollectionVisitable.java
biz/hammurapi/util/CollectionVisitable.java
Violations
Inspector |
Message |
Severity |
Location |
Java Inspector 048 |
Copyrights information should be present in each file. |
1 |
|
Java Inspector 089 |
Undocumented method |
2 |
37:5
|
Java Inspector 089 |
Constructor is not properly documented |
2 |
62:5
|
Java Inspector 089 |
Parameter collection is not documented |
2 |
62:5
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23package biz.hammurapi.util;
24
25import java.util.Collection;
26import java.util.Iterator;
27
28
29
30
31
32
33public class CollectionVisitable implements Visitable {
34 private Collection collection;
35 private boolean visitCollection;
36
37 public boolean accept(Visitor visitor) {
38 if (visitor==null || collection==null) {
39 return false;
40 }
41
42 if (!visitCollection || visitor.visit(collection)) {
43 Iterator it=collection.iterator();
44 while (it.hasNext()) {
45 VisitableBase.object2visitor(it.next(), visitor);
46 }
47
48 if (visitCollection && visitor instanceof PoliteVisitor) {
49 ((PoliteVisitor) visitor).leave(collection);
50 }
51 return true;
52 }
53
54 return false;
55 }
56
57
58
59
60
61
62 public CollectionVisitable(Collection collection, boolean visitCollection) {
63 super();
64 this.collection = collection;
65 this.visitCollection=visitCollection;
66 }
67}
68