1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.qedeq.kernel.dto.module; |
19 |
| |
20 |
| import java.util.ArrayList; |
21 |
| import java.util.List; |
22 |
| |
23 |
| import org.qedeq.kernel.base.module.SubsectionList; |
24 |
| import org.qedeq.kernel.base.module.SubsectionType; |
25 |
| import org.qedeq.kernel.utility.EqualsUtility; |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| public final class SubsectionListVo implements SubsectionList { |
35 |
| |
36 |
| |
37 |
| private final List list; |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
240
| public SubsectionListVo() {
|
43 |
240
| this.list = new ArrayList();
|
44 |
| |
45 |
| } |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
871
| public final void add(final SubsectionType subsection) {
|
53 |
871
| list.add(subsection);
|
54 |
| } |
55 |
| |
56 |
2045
| public final int size() {
|
57 |
2045
| return list.size();
|
58 |
| } |
59 |
| |
60 |
4951
| public final SubsectionType get(final int index) {
|
61 |
4951
| return (SubsectionType) list.get(index);
|
62 |
| } |
63 |
| |
64 |
150
| public boolean equals(final Object obj) {
|
65 |
150
| if (!(obj instanceof SubsectionListVo)) {
|
66 |
6
| return false;
|
67 |
| } |
68 |
144
| final SubsectionListVo otherList = (SubsectionListVo) obj;
|
69 |
144
| if (size() != otherList.size()) {
|
70 |
7
| return false;
|
71 |
| } |
72 |
137
| for (int i = 0; i < size(); i++) {
|
73 |
136
| if (!EqualsUtility.equals(get(i), otherList.get(i))) {
|
74 |
2
| return false;
|
75 |
| } |
76 |
| } |
77 |
135
| return true;
|
78 |
| } |
79 |
| |
80 |
126
| public int hashCode() {
|
81 |
126
| int hash = 0;
|
82 |
126
| for (int i = 0; i < size(); i++) {
|
83 |
124
| hash = hash ^ (i + 1);
|
84 |
124
| if (get(i) != null) {
|
85 |
123
| hash = hash ^ get(i).hashCode();
|
86 |
| } |
87 |
| } |
88 |
126
| return hash;
|
89 |
| } |
90 |
| |
91 |
118
| public String toString() {
|
92 |
118
| final StringBuffer buffer = new StringBuffer("List of nodes:\n");
|
93 |
118
| for (int i = 0; i < size(); i++) {
|
94 |
115
| if (i != 0) {
|
95 |
6
| buffer.append("\n");
|
96 |
| } |
97 |
115
| buffer.append((i + 1) + ":\t");
|
98 |
115
| buffer.append(get(i) != null ? get(i).toString() : null);
|
99 |
| } |
100 |
118
| return buffer.toString();
|
101 |
| } |
102 |
| |
103 |
| } |
104 |
| |