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