1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.metadata;
17
18 import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage;
19 import org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException;
20
21 import javax.xml.bind.annotation.XmlEnum;
22 import javax.xml.bind.annotation.XmlEnumValue;
23 import javax.xml.bind.annotation.XmlType;
24
25
26
27
28
29 @XmlType(name = "DocumentEntryType")
30 @XmlEnum(String.class)
31 public enum DocumentEntryType {
32 @XmlEnumValue("stable") STABLE("urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1"),
33 @XmlEnumValue("on-demand") ON_DEMAND("urn:uuid:34268e47-fdf5-41a6-ba33-82133c465248");
34
35 public static final String[] STABLE_OR_ON_DEMAND = new String[] {
36 STABLE.getUuid(),
37 ON_DEMAND.getUuid(),
38 };
39
40 private final String uuid;
41
42 DocumentEntryType(String uuid) {
43 this.uuid = uuid;
44 }
45
46 public String getUuid() {
47 return uuid;
48 }
49
50 public static String toUuid(DocumentEntryType type) {
51 return (type != null) ? type.uuid : null;
52 }
53
54 public static DocumentEntryType valueOfUuid(String uuid) {
55 for (DocumentEntryType type : DocumentEntryType.values()) {
56 if (type.uuid.equals(uuid)) {
57 return type;
58 }
59 }
60
61 throw new XDSMetaDataException(ValidationMessage.WRONG_DOCUMENT_ENTRY_TYPE, uuid);
62 }
63 }