1 package ca.uhn.fhir.model.primitive;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import static org.apache.commons.lang3.StringUtils.*;
24 import ca.uhn.fhir.model.api.BasePrimitive;
25 import ca.uhn.fhir.model.api.annotation.DatatypeDef;
26 import ca.uhn.fhir.model.api.annotation.SimpleSetter;
27 import ca.uhn.fhir.parser.DataFormatException;
28
29 @DatatypeDef(name = "code")
30 public class CodeDt extends BasePrimitive<String> implements ICodedDatatype, Comparable<CodeDt> {
31
32 private String myValue;
33
34
35
36
37 public CodeDt() {
38 super();
39 }
40
41
42
43
44 @SimpleSetter()
45 public CodeDt(@SimpleSetter.Parameter(name = "theCode") String theCode) {
46 setValue(theCode);
47 }
48
49 @Override
50 public String getValue() {
51 return myValue;
52 }
53
54 @Override
55 public void setValue(String theValue) throws DataFormatException {
56 if (theValue == null) {
57 myValue = null;
58 } else {
59 String newValue = theValue.trim();
60 myValue = newValue;
61 }
62 }
63
64 @Override
65 public void setValueAsString(String theValue) throws DataFormatException {
66 setValue(theValue);
67 }
68
69 @Override
70 public String getValueAsString() {
71 return getValue();
72 }
73
74 @Override
75 public int compareTo(CodeDt theCode) {
76 if (theCode == null) {
77 return 1;
78 }
79 return defaultString(getValue()).compareTo(defaultString(theCode.getValue()));
80 }
81
82 }