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 org.apache.commons.lang3.StringUtils;
24
25 import ca.uhn.fhir.model.api.BasePrimitive;
26 import ca.uhn.fhir.model.api.IQueryParameterType;
27 import ca.uhn.fhir.model.api.annotation.DatatypeDef;
28 import ca.uhn.fhir.model.api.annotation.SimpleSetter;
29 import ca.uhn.fhir.parser.DataFormatException;
30
31 @DatatypeDef(name = "string")
32 public class StringDt extends BasePrimitive<String> implements IQueryParameterType {
33
34 private String myValue;
35
36
37
38
39 public StringDt() {
40 super();
41 }
42
43
44
45
46 @SimpleSetter
47 public StringDt(@SimpleSetter.Parameter(name = "theString") String theValue) {
48 myValue = theValue;
49 }
50
51 @Override
52 public String getValue() {
53 return myValue;
54 }
55
56 public String getValueNotNull() {
57 return StringUtils.defaultString(myValue);
58 }
59
60 @Override
61 public String getValueAsString() {
62 return myValue;
63 }
64
65 @Override
66 public void setValue(String theValue) throws DataFormatException {
67 myValue = theValue;
68 }
69
70 @Override
71 public void setValueAsString(String theValue) throws DataFormatException {
72 myValue = theValue;
73 }
74
75
76
77
78 @Override
79 public String toString() {
80 return myValue;
81 }
82
83 @Override
84 public int hashCode() {
85 final int prime = 31;
86 int result = 1;
87 result = prime * result + ((myValue == null) ? 0 : myValue.hashCode());
88 return result;
89 }
90
91 @Override
92 public boolean equals(Object obj) {
93 if (this == obj)
94 return true;
95 if (obj == null)
96 return false;
97 if (getClass() != obj.getClass())
98 return false;
99 StringDt other = (StringDt) obj;
100 if (myValue == null) {
101 if (other.myValue != null)
102 return false;
103 } else if (!myValue.equals(other.myValue))
104 return false;
105 return true;
106 }
107
108
109
110
111 @Override
112 public void setValueAsQueryToken(String theQualifier, String theValue) {
113 setValue(theValue);
114 }
115
116
117
118
119 @Override
120 public String getValueAsQueryToken() {
121 return getValue();
122 }
123
124
125
126
127 @Override
128 public boolean isEmpty() {
129 boolean retVal = super.isBaseEmpty() && StringUtils.isBlank(getValue());
130 return retVal;
131 }
132
133 @Override
134 public String getQueryParameterQualifier() {
135 return null;
136 }
137
138 }