1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.creadur.whisker.model;
20
21 import java.util.Collection;
22
23
24
25
26
27 public class ByOrganisation implements Comparable<ByOrganisation>, ContentElement {
28
29
30 private final Organisation organisation;
31
32 private final Collection<Resource> resources;
33
34
35
36
37
38
39
40
41
42 public ByOrganisation(final Organisation organisation,
43 final Collection<Resource> resources) {
44 super();
45 this.organisation = organisation;
46 this.resources = resources;
47 }
48
49
50
51
52
53 public String getName() {
54 return this.organisation.getName();
55 }
56
57
58
59
60
61 public String getURL() {
62 return this.organisation.getURL();
63 }
64
65
66
67
68
69 public String getId() {
70 return this.organisation.getId();
71 }
72
73
74
75
76
77 public Collection<Resource> getResources() {
78 return this.resources;
79 }
80
81
82
83
84
85
86 public Organisation getOrganisation() {
87 return this.organisation;
88 }
89
90
91
92
93
94
95 @Override
96 public final int hashCode() {
97 final int prime = 31;
98 int result = 1;
99 result = prime
100 * result
101 + ((this.organisation == null) ? 0 : this.organisation
102 .hashCode());
103 return result;
104 }
105
106
107
108
109
110
111
112
113 @Override
114 public boolean equals(final Object obj) {
115 if (this == obj) {
116 return true;
117 }
118 if (obj == null) {
119 return false;
120 }
121 if (getClass() != obj.getClass()) {
122 return false;
123 }
124 final ByOrganisation other = (ByOrganisation) obj;
125 if (this.organisation == null) {
126 if (other.organisation != null) {
127 return false;
128 }
129 } else if (!this.organisation.equals(other.organisation)) {
130 return false;
131 }
132 return true;
133 }
134
135
136
137
138
139
140
141 public int compareTo(final ByOrganisation other) {
142 return this.organisation.compareTo(other.getOrganisation());
143 }
144
145
146
147
148
149 public void accept(final Visitor visitor) {
150 if (visitor != null && visitor.traverseByOrganisation()) {
151 visitor.visit(this);
152 for (final Resource resource : getResources()) {
153 resource.accept(visitor);
154 }
155 }
156 }
157
158
159
160
161
162 @Override
163 public String toString() {
164 return "ByOrganisation [organisation=" + this.organisation
165 + ", resources=" + this.resources + "]";
166 }
167 }