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.Map;
22
23
24
25
26
27 public class Organisation implements Comparable<Organisation> {
28
29
30 private final String id;
31
32 private final String name;
33
34 private final String url;
35
36
37
38
39
40
41
42
43
44
45
46 public Organisation(final String id, final String name, final String url) {
47 super();
48 this.id = id;
49 this.name = name;
50 this.url = url;
51 }
52
53
54
55
56
57
58 public Organisation storeIn(
59 final Map<String, Organisation> organisationsById) {
60 organisationsById.put(this.id, this);
61 return this;
62 }
63
64
65
66
67
68
69 public String getName() {
70 return this.name;
71 }
72
73
74
75
76
77
78 public String getURL() {
79 return this.url;
80 }
81
82
83
84
85
86
87
88 public String getId() {
89 return this.id;
90 }
91
92 @Override
93 public int hashCode() {
94 final int prime = 31;
95 int result = 1;
96 result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
97 return result;
98 }
99
100 @Override
101 public boolean equals(final Object obj) {
102 if (this == obj) {
103 return true;
104 }
105 if (obj == null) {
106 return false;
107 }
108 if (getClass() != obj.getClass()) {
109 return false;
110 }
111 final Organisation other = (Organisation) obj;
112 if (this.id == null) {
113 if (other.id != null) {
114 return false;
115 }
116 } else if (!this.id.equals(other.id)) {
117 return false;
118 }
119 return true;
120 }
121
122
123
124
125 public int compareTo(final Organisation other) {
126 final int nameDifference = getName().compareTo(other.getName());
127 return nameDifference == 0 ? getId().compareTo(other.getId())
128 : nameDifference;
129 }
130
131 @Override
132 public String toString() {
133 return "Organisation [id=" + this.id + ", name=" + this.name + ", url="
134 + this.url + "]";
135 }
136 }