|
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.Section; |
|
24 |
| import org.qedeq.kernel.base.module.SectionList; |
|
25 |
| import org.qedeq.kernel.utility.EqualsUtility; |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| public class SectionListVo implements SectionList { |
|
35 |
| |
|
36 |
| |
|
37 |
| private final List list; |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
250
| public SectionListVo() {
|
|
43 |
250
| this.list = new ArrayList();
|
|
44 |
| |
|
45 |
| } |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
555
| public final void add(final SectionVo section) {
|
|
53 |
555
| list.add(section);
|
|
54 |
| } |
|
55 |
| |
|
56 |
71251
| public final int size() {
|
|
57 |
71251
| return list.size();
|
|
58 |
| } |
|
59 |
| |
|
60 |
98347
| public final Section get(final int index) {
|
|
61 |
98347
| return (Section) list.get(index);
|
|
62 |
| } |
|
63 |
| |
|
64 |
134
| public boolean equals(final Object obj) {
|
|
65 |
134
| if (!(obj instanceof SectionListVo)) {
|
|
66 |
7
| return false;
|
|
67 |
| } |
|
68 |
127
| final SectionListVo otherList = (SectionListVo) obj;
|
|
69 |
127
| if (size() != otherList.size()) {
|
|
70 |
11
| return false;
|
|
71 |
| } |
|
72 |
116
| for (int i = 0; i < size(); i++) {
|
|
73 |
122
| if (!EqualsUtility.equals(get(i), otherList.get(i))) {
|
|
74 |
4
| return false;
|
|
75 |
| } |
|
76 |
| } |
|
77 |
112
| return true;
|
|
78 |
| } |
|
79 |
| |
|
80 |
100
| public int hashCode() {
|
|
81 |
100
| int hash = 0;
|
|
82 |
100
| for (int i = 0; i < size(); i++) {
|
|
83 |
102
| hash = hash ^ (i + 1);
|
|
84 |
102
| if (get(i) != null) {
|
|
85 |
100
| hash = hash ^ get(i).hashCode();
|
|
86 |
| } |
|
87 |
| } |
|
88 |
100
| return hash;
|
|
89 |
| } |
|
90 |
| |
|
91 |
95
| public String toString() {
|
|
92 |
95
| final StringBuffer buffer = new StringBuffer("List of sections:\n");
|
|
93 |
95
| for (int i = 0; i < size(); i++) {
|
|
94 |
96
| if (i != 0) {
|
|
95 |
10
| buffer.append("\n");
|
|
96 |
| } |
|
97 |
96
| buffer.append((i + 1) + ":\t");
|
|
98 |
96
| buffer.append(get(i) != null ? get(i).toString() : null);
|
|
99 |
| } |
|
100 |
95
| return buffer.toString();
|
|
101 |
| } |
|
102 |
| |
|
103 |
| } |