You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @throws IllegalStateException if the passed String is not a valid FHIR String value
56
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
57
+
* methods can throw the most appropriate exception without catching and wrapping.
58
+
*/
45
59
publicstaticvoidcheckString(Strings) {
46
60
if (s == null) {
47
61
return;
@@ -59,11 +73,22 @@ public static void checkString(String s) {
59
73
thrownewIllegalStateException(String.format("String value: '%s' is not valid with respect to pattern: [ \\r\\n\\t\\S]+", s));
60
74
}
61
75
}
62
-
if (count < MIN_LENGTH) {
63
-
thrownewIllegalStateException(String.format("Trimmed String value length: %d is less than minimum required length: %d", count, MIN_LENGTH));
76
+
if (count < MIN_STRING_LENGTH) {
77
+
thrownewIllegalStateException(String.format("Trimmed String value length: %d is less than minimum required length: %d", count, MIN_STRING_LENGTH));
64
78
}
65
79
}
66
80
81
+
/**
82
+
* A string which has at least one character and no leading or trailing whitespace and where there is no whitespace other
83
+
* than single spaces in the contents.
84
+
* <pre>
85
+
* pattern: [^\s]+(\s[^\s]+)*
86
+
* </pre>
87
+
*
88
+
* @throws IllegalStateException if the passed String is not a valid FHIR Code value
89
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
90
+
* methods can throw the most appropriate exception without catching and wrapping.
91
+
*/
67
92
publicstaticvoidcheckCode(Strings) {
68
93
if (s == null) {
69
94
return;
@@ -93,6 +118,54 @@ public static void checkCode(String s) {
93
118
}
94
119
}
95
120
121
+
/**
122
+
* Any combination of letters, numerals, "-" and ".", with a length limit of 64 characters. (This might be an integer, an
123
+
* unprefixed OID, UUID or any other identifier pattern that meets these constraints.) Ids are case-insensitive.
124
+
* <pre>
125
+
* pattern: [A-Za-z0-9\-\.]{1,64}
126
+
* </pre>
127
+
*
128
+
* @throws IllegalStateException if the passed String is not a valid FHIR Id value
129
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
130
+
* methods can throw the most appropriate exception without catching and wrapping.
131
+
*/
132
+
publicstaticvoidcheckId(Strings) {
133
+
if (s == null) {
134
+
return;
135
+
}
136
+
if (s.isEmpty()) {
137
+
thrownewIllegalStateException(String.format("Id value must not be empty"));
138
+
}
139
+
if (s.length() > 64) {
140
+
thrownewIllegalStateException(String.format("Id value length: %d is greater than maximum allowed length: %d", s.length(), 64));
141
+
}
142
+
143
+
for (inti = 0; i < s.length(); i++) {
144
+
charc = s.charAt(i);
145
+
//45 = '-'
146
+
//46 = '.'
147
+
//48 = '0'
148
+
//57 = '9'
149
+
//65 = 'A'
150
+
//90 = 'Z'
151
+
//97 = 'a'
152
+
//122 = 'z'
153
+
if (c < 45 || c == 47 || (c > 57 && c < 65) || (c > 90 && c < 97) || c > 122 ) {
154
+
thrownewIllegalStateException(String.format("Id value: '%s' contain invalid character '%s'", s, c));
155
+
}
156
+
}
157
+
}
158
+
159
+
/**
160
+
* String of characters used to identify a name or a resource
161
+
* <pre>
162
+
* pattern: \S*
163
+
* </pre>
164
+
*
165
+
* @throws IllegalStateException if the passed String is not a valid FHIR Id value
166
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
167
+
* methods can throw the most appropriate exception without catching and wrapping.
168
+
*/
96
169
publicstaticvoidcheckUri(Strings) {
97
170
if (s == null) {
98
171
return;
@@ -108,6 +181,11 @@ public static void checkUri(String s) {
108
181
}
109
182
}
110
183
184
+
/**
185
+
* @throws IllegalStateException if the passed String is longer than the maximum string length
186
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
187
+
* methods can throw the most appropriate exception without catching and wrapping.
188
+
*/
111
189
publicstaticvoidcheckMaxLength(Stringvalue) {
112
190
if (value != null) {
113
191
if (value.length() > MAX_STRING_LENGTH) {
@@ -116,14 +194,24 @@ public static void checkMaxLength(String value) {
116
194
}
117
195
}
118
196
197
+
/**
198
+
* @throws IllegalStateException if the passed String is shorter than the minimum string length
199
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
200
+
* methods can throw the most appropriate exception without catching and wrapping.
201
+
*/
119
202
publicstaticvoidcheckMinLength(Stringvalue) {
120
203
if (value != null) {
121
-
if (value.trim().length() < MIN_LENGTH) {
122
-
thrownewIllegalStateException(String.format("String value length: %d is less than minimum required length: %d", value.trim().length(), MIN_LENGTH));
204
+
if (value.trim().length() < MIN_STRING_LENGTH) {
205
+
thrownewIllegalStateException(String.format("Trimmed String value length: %d is less than minimum required length: %d", value.trim().length(), MIN_STRING_LENGTH));
123
206
}
124
207
}
125
208
}
126
209
210
+
/**
211
+
* @throws IllegalStateException if the passed Integer value is less than the passed minValue
212
+
* @apiNote IllegalStateException is chosen in favor of IllegalArgumentException so that Builder.build()
213
+
* methods can throw the most appropriate exception without catching and wrapping.
0 commit comments