Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/Recommendation.java @ 9566:9826b465b751
serialVersionUID introduced
author | gernotbelger |
---|---|
date | Mon, 05 Nov 2018 10:19:12 +0100 |
parents | 8d9859d776e5 |
children |
comparison
equal
deleted
inserted
replaced
9565:4809e23ffd27 | 9566:9826b465b751 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.shared.model; | 9 package org.dive4elements.river.client.shared.model; |
10 | 10 |
11 | 11 import java.io.Serializable; |
12 import java.util.HashMap; | |
12 import java.util.List; | 13 import java.util.List; |
13 import java.util.Map; | 14 import java.util.Map; |
14 import java.util.HashMap; | |
15 | |
16 import java.io.Serializable; | |
17 | 15 |
18 /** | 16 /** |
19 * Information bundle to let client create/clone an artifact with facets. | 17 * Information bundle to let client create/clone an artifact with facets. |
18 * | |
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
21 */ | 20 */ |
22 public class Recommendation implements Serializable { | 21 public class Recommendation implements Serializable { |
23 | 22 |
23 private static final long serialVersionUID = 1L; | |
24 | |
24 /** Index and name of a facet. */ | 25 /** Index and name of a facet. */ |
25 public static class Facet implements Serializable { | 26 public static class Facet implements Serializable { |
26 | 27 |
28 private static final long serialVersionUID = 1L; | |
29 | |
27 /** Facet name. */ | 30 /** Facet name. */ |
28 protected String name; | 31 protected String name; |
29 | 32 |
30 /** Facet index. */ | 33 /** Facet index. */ |
31 protected String index; | 34 protected String index; |
32 | 35 |
33 public Facet() { | 36 public Facet() { |
34 } | 37 } |
35 | 38 |
36 public Facet(String name, String index) { | 39 public Facet(final String name, final String index) { |
37 this.name = name; | 40 this.name = name; |
38 this.index = index; | 41 this.index = index; |
39 } | 42 } |
40 | 43 |
41 public String getName() { | 44 public String getName() { |
42 return name; | 45 return this.name; |
43 } | 46 } |
44 | 47 |
45 public String getIndex() { | 48 public String getIndex() { |
46 return index; | 49 return this.index; |
47 } | 50 } |
48 | |
49 | 51 |
50 @Override | 52 @Override |
51 public int hashCode() { | 53 public int hashCode() { |
52 int hash = 0; | 54 int hash = 0; |
53 if (getName() != null) { | 55 if (getName() != null) { |
57 hash += getIndex().hashCode(); | 59 hash += getIndex().hashCode(); |
58 } | 60 } |
59 return hash; | 61 return hash; |
60 } | 62 } |
61 | 63 |
62 | 64 @Override |
63 @Override | 65 public boolean equals(final Object other) { |
64 public boolean equals(Object other) { | |
65 if (!(other instanceof Facet) || other == null) { | 66 if (!(other instanceof Facet) || other == null) { |
66 return false; | 67 return false; |
67 } | 68 } |
68 Facet facet = (Facet) other; | 69 final Facet facet = (Facet) other; |
69 return (same(facet.getIndex(), this.getIndex())) | 70 return (same(facet.getIndex(), this.getIndex())) && (same(facet.getName(), this.getName())); |
70 && (same(facet.getName(), this.getName())); | |
71 } | 71 } |
72 } // class Facet | 72 } // class Facet |
73 | |
74 | 73 |
75 /** Mapping of outnames to Facet-Lists. */ | 74 /** Mapping of outnames to Facet-Lists. */ |
76 public static class Filter implements Serializable { | 75 public static class Filter implements Serializable { |
77 | 76 |
78 protected Map<String, List<Facet>> outs; | 77 protected Map<String, List<Facet>> outs; |
79 | 78 |
80 public Filter() { | 79 public Filter() { |
81 outs = new HashMap<String, List<Facet>>(); | 80 this.outs = new HashMap<String, List<Facet>>(); |
82 } | 81 } |
83 | 82 |
84 public void add(String out, List<Facet> facets) { | 83 public void add(final String out, final List<Facet> facets) { |
85 outs.put(out, facets); | 84 this.outs.put(out, facets); |
86 } | 85 } |
87 | 86 |
88 public Map<String, List<Facet>> getOuts() { | 87 public Map<String, List<Facet>> getOuts() { |
89 return outs; | 88 return this.outs; |
90 } | 89 } |
91 | |
92 | 90 |
93 @Override | 91 @Override |
94 public int hashCode() { | 92 public int hashCode() { |
95 if (getOuts() != null) { | 93 if (getOuts() != null) { |
96 return getOuts().hashCode(); | 94 return getOuts().hashCode(); |
97 } | 95 } |
98 return 0; | 96 return 0; |
99 } | 97 } |
100 | 98 |
101 | 99 @Override |
102 @Override | 100 public boolean equals(final Object other) { |
103 public boolean equals(Object other) { | |
104 if (!(other instanceof Filter) || other == null) { | 101 if (!(other instanceof Filter) || other == null) { |
105 return false; | 102 return false; |
106 } | 103 } |
107 Filter filter = (Filter) other; | 104 final Filter filter = (Filter) other; |
108 return Recommendation.same(filter.getOuts(), this.getOuts()); | 105 return Recommendation.same(filter.getOuts(), this.getOuts()); |
109 } | 106 } |
110 } // class Filter | 107 } // class Filter |
111 | 108 |
112 /** Factory to speak to when creating/cloning. */ | 109 /** Factory to speak to when creating/cloning. */ |
123 protected String displayName = null; | 120 protected String displayName = null; |
124 | 121 |
125 public Recommendation() { | 122 public Recommendation() { |
126 } | 123 } |
127 | 124 |
128 public Recommendation(String factory, String ids) { | 125 public Recommendation(final String factory, final String ids) { |
129 this(factory, ids, null, null); | 126 this(factory, ids, null, null); |
130 } | 127 } |
131 | 128 |
132 public Recommendation(String factory, String ids, String targetOut) { | 129 public Recommendation(final String factory, final String ids, final String targetOut) { |
133 this(factory, ids, null, null, targetOut); | 130 this(factory, ids, null, null, targetOut); |
134 } | 131 } |
135 | 132 |
136 public Recommendation( | 133 public Recommendation(final String factory, final String ids, final String masterArtifact, final Filter filter) { |
137 String factory, | |
138 String ids, | |
139 String masterArtifact, | |
140 Filter filter | |
141 ) { | |
142 this(factory, ids, masterArtifact, filter, null); | 134 this(factory, ids, masterArtifact, filter, null); |
143 } | 135 } |
144 | 136 |
145 public Recommendation( | 137 public Recommendation(final String factory, final String ids, final String masterArtifact, final Filter filter, final String targetOut) { |
146 String factory, | 138 this.factory = factory; |
147 String ids, | 139 this.ids = ids; |
148 String masterArtifact, | |
149 Filter filter, | |
150 String targetOut | |
151 ) { | |
152 this.factory = factory; | |
153 this.ids = ids; | |
154 this.masterArtifact = masterArtifact; | 140 this.masterArtifact = masterArtifact; |
155 this.filter = filter; | 141 this.filter = filter; |
156 this.targetOut = targetOut; | 142 this.targetOut = targetOut; |
157 } | 143 } |
158 | 144 |
159 public String getTargetOut() { | 145 public String getTargetOut() { |
160 return targetOut; | 146 return this.targetOut; |
161 } | 147 } |
162 | 148 |
163 public void setTargetOut(String value) { | 149 public void setTargetOut(final String value) { |
164 targetOut = value; | 150 this.targetOut = value; |
165 } | 151 } |
166 | 152 |
167 public String getFactory() { | 153 public String getFactory() { |
168 return factory; | 154 return this.factory; |
169 } | 155 } |
170 | 156 |
171 public void setFactory(String factory) { | 157 public void setFactory(final String factory) { |
172 this.factory = factory; | 158 this.factory = factory; |
173 } | 159 } |
174 | 160 |
175 public void setDisplayName(String displayName) { | 161 public void setDisplayName(final String displayName) { |
176 this.displayName = displayName; | 162 this.displayName = displayName; |
177 } | 163 } |
178 | 164 |
179 public String getDisplayName() { | 165 public String getDisplayName() { |
180 return this.displayName; | 166 return this.displayName; |
181 } | 167 } |
182 | 168 |
183 public String getIDs() { | 169 public String getIDs() { |
184 return ids; | 170 return this.ids; |
185 } | 171 } |
186 | 172 |
187 public String getMasterArtifact() { | 173 public String getMasterArtifact() { |
188 return masterArtifact; | 174 return this.masterArtifact; |
189 } | 175 } |
190 | 176 |
191 public void setMasterArtifact(String masterArtifact) { | 177 public void setMasterArtifact(final String masterArtifact) { |
192 this.masterArtifact = masterArtifact; | 178 this.masterArtifact = masterArtifact; |
193 } | 179 } |
194 | 180 |
195 public Filter getFilter() { | 181 public Filter getFilter() { |
196 return filter; | 182 return this.filter; |
197 } | 183 } |
198 | 184 |
199 public void setFilter(Filter filter) { | 185 public void setFilter(final Filter filter) { |
200 this.filter = filter; | 186 this.filter = filter; |
201 } | 187 } |
202 | |
203 | 188 |
204 @Override | 189 @Override |
205 public int hashCode() { | 190 public int hashCode() { |
206 int hash = 0; | 191 int hash = 0; |
207 hash += (getFactory() != null) | 192 hash += (getFactory() != null) ? getFactory().hashCode() : 0; |
208 ? getFactory().hashCode() | 193 hash += (getIDs() != null) ? getIDs().hashCode() : 0; |
209 : 0; | 194 hash += (getFilter() != null) ? getFilter().hashCode() : 0; |
210 hash += (getIDs() != null) | 195 hash += (getMasterArtifact() != null) ? getMasterArtifact().hashCode() : 0; |
211 ? getIDs().hashCode() | 196 hash += (getTargetOut() != null) ? getTargetOut().hashCode() : 0; |
212 : 0; | |
213 hash += (getFilter() != null) | |
214 ? getFilter().hashCode() | |
215 : 0; | |
216 hash += (getMasterArtifact() != null) | |
217 ? getMasterArtifact().hashCode() | |
218 : 0; | |
219 hash += (getTargetOut() != null) | |
220 ? getTargetOut().hashCode() | |
221 : 0; | |
222 return hash; | 197 return hash; |
223 } | 198 } |
224 | |
225 | 199 |
226 /** | 200 /** |
227 * Null-pointer guarded equals. | 201 * Null-pointer guarded equals. |
228 * Two null's are assumed equal (returns true); | 202 * Two null's are assumed equal (returns true); |
229 * @param a Object to compare against parameter b. | 203 * |
230 * @param b Object to compare against parameter a. | 204 * @param a |
205 * Object to compare against parameter b. | |
206 * @param b | |
207 * Object to compare against parameter a. | |
231 * @return true if either a and b are null or a.equals(b) returns true. | 208 * @return true if either a and b are null or a.equals(b) returns true. |
232 */ | 209 */ |
233 protected static boolean same(Object a, Object b) { | 210 protected static boolean same(final Object a, final Object b) { |
234 // Do null-check. | 211 // Do null-check. |
235 if (a == null) { | 212 if (a == null) { |
236 return b == null; | 213 return b == null; |
237 } else if (b == null) { | 214 } else if (b == null) { |
238 return false; | 215 return false; |
239 } | 216 } |
240 return a.equals(b); | 217 return a.equals(b); |
241 } | 218 } |
242 | 219 |
243 | |
244 @Override | 220 @Override |
245 public boolean equals(Object other) { | 221 public boolean equals(final Object other) { |
246 if (!(other instanceof Recommendation) || other == null) { | 222 if (!(other instanceof Recommendation) || other == null) { |
247 return false; | 223 return false; |
248 } | 224 } |
249 Recommendation rec = (Recommendation) other; | 225 final Recommendation rec = (Recommendation) other; |
250 return (same(this.getFactory(), rec.getFactory())) | 226 return (same(this.getFactory(), rec.getFactory())) && (same(this.getIDs(), rec.getIDs())) && (same(this.getFilter(), rec.getFilter())) |
251 && (same(this.getIDs(), rec.getIDs())) | 227 && (same(this.getMasterArtifact(), rec.getMasterArtifact())) && (same(this.getTargetOut(), rec.getTargetOut())); |
252 && (same(this.getFilter(), rec.getFilter())) | |
253 && (same(this.getMasterArtifact(), rec.getMasterArtifact())) | |
254 && (same(this.getTargetOut(), rec.getTargetOut())); | |
255 } | 228 } |
256 } | 229 } |
257 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |