Revision 2caedd4f
Added by Andreas Müller over 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmPreference.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.model.metadata; |
10 | 10 |
|
11 | 11 |
import java.io.Serializable; |
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
12 | 15 |
|
13 | 16 |
import javax.persistence.Column; |
14 | 17 |
import javax.persistence.Embeddable; |
15 | 18 |
import javax.persistence.EmbeddedId; |
16 | 19 |
import javax.persistence.Entity; |
17 | 20 |
|
21 |
import org.apache.commons.lang3.StringUtils; |
|
22 |
|
|
18 | 23 |
|
19 | 24 |
/** |
20 | 25 |
* This class may hold all prefrences data for a CDM database. |
... | ... | |
191 | 196 |
} |
192 | 197 |
|
193 | 198 |
|
199 |
/** |
|
200 |
* @return the subject of the preference |
|
201 |
*/ |
|
194 | 202 |
public String getSubject() { |
195 | 203 |
return key.subject; |
196 | 204 |
} |
197 | 205 |
|
206 |
/** |
|
207 |
* @return the predicate of the preference |
|
208 |
*/ |
|
198 | 209 |
public String getPredicate() { |
199 | 210 |
return key.predicate; |
200 | 211 |
} |
201 | 212 |
|
213 |
/** |
|
214 |
* @return the value of the preference |
|
215 |
*/ |
|
202 | 216 |
public String getValue() { |
203 | 217 |
return value; |
204 | 218 |
} |
205 | 219 |
|
220 |
/** |
|
221 |
* Returns the {@link #getValue() value} as {@link UUID} List. |
|
222 |
* Throws an exception if the value can not be parsed as UUID list. |
|
223 |
* @return |
|
224 |
* @throws IllegalArgumentException |
|
225 |
*/ |
|
226 |
public List<UUID> getValueUuidList() throws IllegalArgumentException { |
|
227 |
List<UUID> result = new ArrayList<>(); |
|
228 |
if (StringUtils.isBlank(value)){ |
|
229 |
return result; |
|
230 |
} |
|
231 |
String[] splits = getValue().split("[,;]"); |
|
232 |
for (String split : splits ){ |
|
233 |
try { |
|
234 |
if (StringUtils.isBlank(split)){ |
|
235 |
continue; //neglect trailing separators |
|
236 |
} |
|
237 |
UUID uuid = UUID.fromString(split.trim()); |
|
238 |
result.add(uuid); |
|
239 |
} catch (IllegalArgumentException e) { |
|
240 |
throw e; |
|
241 |
} |
|
242 |
} |
|
243 |
return result; |
|
244 |
} |
|
245 |
|
|
246 |
|
|
206 | 247 |
// |
207 | 248 |
// we try to avoid setting of values |
208 | 249 |
// public void setValue(String value) { |
Also available in: Unified diff
add uuid list as return type for CdmPreference.getValue