@@ -93,138 +93,6 @@ static PatternFormat pattern(String name, String regex) {
93
93
COMMON_BUILTIN_FORMATS .add (pattern ("style" , "\\ s*(.+?):\\ s*([^;]+);?" ));
94
94
}
95
95
96
- private static class V4 {
97
- private static String URI = "https://json-schema.org/draft-04/schema" ;
98
- private static final String ID = "id" ;
99
-
100
- public static final List <Format > BUILTIN_FORMATS = new ArrayList <Format >(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
101
-
102
- static {
103
- // add version specific formats here.
104
- //BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
105
- }
106
-
107
- public static JsonMetaSchema getInstance () {
108
- return new Builder (URI )
109
- .idKeyword (ID )
110
- .addFormats (BUILTIN_FORMATS )
111
- .addKeywords (ValidatorTypeCode .getNonFormatKeywords (SpecVersion .VersionFlag .V4 ))
112
- // keywords that may validly exist, but have no validation aspect to them
113
- .addKeywords (Arrays .asList (
114
- new NonValidationKeyword ("$schema" ),
115
- new NonValidationKeyword ("id" ),
116
- new NonValidationKeyword ("title" ),
117
- new NonValidationKeyword ("description" ),
118
- new NonValidationKeyword ("default" ),
119
- new NonValidationKeyword ("definitions" ),
120
- new NonValidationKeyword ("exampleSetFlag" )
121
- ))
122
- .build ();
123
- }
124
- }
125
-
126
- private static class V6 {
127
- private static String URI = "https://json-schema.org/draft-06/schema" ;
128
- // Draft 6 uses "$id"
129
- private static final String ID = "$id" ;
130
-
131
- public static final List <Format > BUILTIN_FORMATS = new ArrayList <Format >(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
132
-
133
- static {
134
- // add version specific formats here.
135
- //BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
136
- }
137
-
138
- public static JsonMetaSchema getInstance () {
139
- return new Builder (URI )
140
- .idKeyword (ID )
141
- .addFormats (BUILTIN_FORMATS )
142
- .addKeywords (ValidatorTypeCode .getNonFormatKeywords (SpecVersion .VersionFlag .V6 ))
143
- // keywords that may validly exist, but have no validation aspect to them
144
- .addKeywords (Arrays .asList (
145
- new NonValidationKeyword ("$schema" ),
146
- new NonValidationKeyword ("$id" ),
147
- new NonValidationKeyword ("title" ),
148
- new NonValidationKeyword ("description" ),
149
- new NonValidationKeyword ("default" ),
150
- new NonValidationKeyword ("definitions" )
151
- ))
152
- .build ();
153
- }
154
- }
155
-
156
- private static class V7 {
157
- private static String URI = "https://json-schema.org/draft-07/schema" ;
158
- private static final String ID = "$id" ;
159
-
160
- public static final List <Format > BUILTIN_FORMATS = new ArrayList <Format >(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
161
-
162
- static {
163
- // add version specific formats here.
164
- //BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
165
- }
166
-
167
- public static JsonMetaSchema getInstance () {
168
- return new Builder (URI )
169
- .idKeyword (ID )
170
- .addFormats (BUILTIN_FORMATS )
171
- .addKeywords (ValidatorTypeCode .getNonFormatKeywords (SpecVersion .VersionFlag .V7 ))
172
- // keywords that may validly exist, but have no validation aspect to them
173
- .addKeywords (Arrays .asList (
174
- new NonValidationKeyword ("$schema" ),
175
- new NonValidationKeyword ("$id" ),
176
- new NonValidationKeyword ("title" ),
177
- new NonValidationKeyword ("description" ),
178
- new NonValidationKeyword ("default" ),
179
- new NonValidationKeyword ("definitions" ),
180
- new NonValidationKeyword ("$comment" ),
181
- new NonValidationKeyword ("contentMediaType" ),
182
- new NonValidationKeyword ("contentEncoding" ),
183
- new NonValidationKeyword ("examples" ),
184
- new NonValidationKeyword ("message" )
185
- ))
186
- .build ();
187
- }
188
- }
189
-
190
- private static class V201909 {
191
- private static String URI = "https://json-schema.org/draft/2019-09/schema" ;
192
- private static final String ID = "$id" ;
193
-
194
- public static final List <Format > BUILTIN_FORMATS = new ArrayList <Format >(JsonMetaSchema .COMMON_BUILTIN_FORMATS );
195
-
196
- static {
197
- // add version specific formats here.
198
- //BUILTIN_FORMATS.add(pattern("phone", "^\\+(?:[0-9] ?){6,14}[0-9]$"));
199
- }
200
-
201
- public static JsonMetaSchema getInstance () {
202
- return new Builder (URI )
203
- .idKeyword (ID )
204
- .addFormats (BUILTIN_FORMATS )
205
- .addKeywords (ValidatorTypeCode .getNonFormatKeywords (SpecVersion .VersionFlag .V201909 ))
206
- // keywords that may validly exist, but have no validation aspect to them
207
- .addKeywords (Arrays .asList (
208
- new NonValidationKeyword ("$schema" ),
209
- new NonValidationKeyword ("$id" ),
210
- new NonValidationKeyword ("title" ),
211
- new NonValidationKeyword ("description" ),
212
- new NonValidationKeyword ("default" ),
213
- new NonValidationKeyword ("definitions" ),
214
- new NonValidationKeyword ("$comment" ),
215
- new NonValidationKeyword ("$defs" ), // newly added in 2019-09 release.
216
- new NonValidationKeyword ("$anchor" ),
217
- new NonValidationKeyword ("additionalItems" ),
218
- new NonValidationKeyword ("deprecated" ),
219
- new NonValidationKeyword ("contentMediaType" ),
220
- new NonValidationKeyword ("contentEncoding" ),
221
- new NonValidationKeyword ("examples" ),
222
- new NonValidationKeyword ("then" )
223
- ))
224
- .build ();
225
- }
226
- }
227
-
228
96
public static class Builder {
229
97
private Map <String , Keyword > keywords = new HashMap <String , Keyword >();
230
98
private Map <String , Format > formats = new HashMap <String , Format >();
@@ -312,19 +180,19 @@ private JsonMetaSchema(String uri, String idKeyword, Map<String, Keyword> keywor
312
180
}
313
181
314
182
public static JsonMetaSchema getV4 () {
315
- return V4 .getInstance ();
183
+ return new Version4 () .getInstance ();
316
184
}
317
185
318
186
public static JsonMetaSchema getV6 () {
319
- return V6 .getInstance ();
187
+ return new Version6 () .getInstance ();
320
188
}
321
189
322
190
public static JsonMetaSchema getV7 () {
323
- return V7 .getInstance ();
191
+ return new Version7 () .getInstance ();
324
192
}
325
193
326
194
public static JsonMetaSchema getV201909 () {
327
- return V201909 .getInstance ();
195
+ return new Version201909 () .getInstance ();
328
196
}
329
197
330
198
/**
0 commit comments