1 package ca.uhn.fhir.model.api;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import ca.uhn.fhir.model.primitive.IdDt;
24 import ca.uhn.fhir.parser.DataFormatException;
25 import ca.uhn.fhir.util.CoverageIgnore;
26
27 public abstract class BaseIdentifiableElement extends BaseElement implements IIdentifiableElement {
28
29 private static final long serialVersionUID = -7816838417076777914L;
30 private String myElementSpecificId;
31
32 @Override
33 public String getElementSpecificId() {
34 return myElementSpecificId;
35 }
36
37
38
39
40
41 @CoverageIgnore
42 @Deprecated
43 @Override
44 public IdDt getId() {
45 if (myElementSpecificId == null) {
46 return new LockedId();
47 }
48 return new LockedId(myElementSpecificId);
49 }
50
51 @Override
52 public void setElementSpecificId(String theElementSpecificId) {
53 myElementSpecificId = theElementSpecificId;
54 }
55
56
57
58
59
60 @CoverageIgnore
61 @Deprecated
62 @Override
63 public void setId(IdDt theId) {
64 if (theId == null) {
65 myElementSpecificId = null;
66 } else {
67 myElementSpecificId = theId.getValue();
68 }
69 }
70
71
72
73
74
75 @CoverageIgnore
76 @Override
77 @Deprecated
78 public void setId(String theId) {
79 myElementSpecificId = theId;
80 }
81
82 @CoverageIgnore
83 private static class LockedId extends IdDt {
84
85 @CoverageIgnore
86 public LockedId() {
87 }
88
89 @CoverageIgnore
90 public LockedId(String theElementSpecificId) {
91 super(theElementSpecificId);
92 }
93
94 @Override
95 @CoverageIgnore
96 public IdDt setValue(String theValue) throws DataFormatException {
97 throw new UnsupportedOperationException("Use IElement#setElementSpecificId(String) to set the element ID for an element");
98 }
99
100 @Override
101 @CoverageIgnore
102 public void setValueAsString(String theValue) throws DataFormatException {
103 throw new UnsupportedOperationException("Use IElement#setElementSpecificId(String) to set the element ID for an element");
104 }
105
106 }
107
108 }