@@ -39,6 +39,8 @@ private static final Regexp toRegexp(String pattern) {
39
39
40
40
private boolean requiresObject = true ;
41
41
42
+ private final Map <String , Schema > definitionSchemas = new HashMap <>();
43
+
42
44
private final Map <String , Schema > propertySchemas = new HashMap <>();
43
45
44
46
private boolean additionalProperties = true ;
@@ -64,6 +66,22 @@ public Builder additionalProperties(boolean additionalProperties) {
64
66
return this ;
65
67
}
66
68
69
+ /**
70
+ * Adds a definition schema.
71
+ *
72
+ * @param definitionName
73
+ * the name of the definition
74
+ * @param schema
75
+ * the definition of the {@code schema}
76
+ * @return {@code this}
77
+ */
78
+ public Builder addDefinitionSchema (String definitionName , Schema schema ) {
79
+ requireNonNull (definitionName , "definitionName cannot be null" );
80
+ requireNonNull (schema , "schema cannot be null" );
81
+ definitionSchemas .put (definitionName , schema );
82
+ return this ;
83
+ }
84
+
67
85
/**
68
86
* Adds a property schema.
69
87
*
@@ -170,6 +188,8 @@ private static <K, V> Map<K, V> copyMap(Map<K, V> original) {
170
188
return Collections .unmodifiableMap (new HashMap <>(original ));
171
189
}
172
190
191
+ private final Map <String , Schema > definitionSchemas ;
192
+
173
193
private final Map <String , Schema > propertySchemas ;
174
194
175
195
private final boolean additionalProperties ;
@@ -202,8 +222,10 @@ private static <K, V> Map<K, V> copyMap(Map<K, V> original) {
202
222
*/
203
223
public ObjectSchema (Builder builder ) {
204
224
super (builder );
225
+ this .definitionSchemas = builder .definitionSchemas == null ? null
226
+ : Collections .unmodifiableMap (builder .definitionSchemas );
205
227
this .propertySchemas = builder .propertySchemas == null ? null
206
- : Collections .unmodifiableMap (builder .propertySchemas );
228
+ : Collections .unmodifiableMap (builder .propertySchemas );
207
229
this .additionalProperties = builder .additionalProperties ;
208
230
this .schemaOfAdditionalProperties = builder .schemaOfAdditionalProperties ;
209
231
if (!additionalProperties && schemaOfAdditionalProperties != null ) {
@@ -248,6 +270,10 @@ public Map<String, Set<String>> getPropertyDependencies() {
248
270
return propertyDependencies ;
249
271
}
250
272
273
+ public Map <String , Schema > getDefinitionSchemas () {
274
+ return definitionSchemas ;
275
+ }
276
+
251
277
public Map <String , Schema > getPropertySchemas () {
252
278
return propertySchemas ;
253
279
}
@@ -344,6 +370,7 @@ public boolean equals(Object o) {
344
370
return that .canEqual (this ) &&
345
371
additionalProperties == that .additionalProperties &&
346
372
requiresObject == that .requiresObject &&
373
+ Objects .equals (definitionSchemas , that .definitionSchemas ) &&
347
374
Objects .equals (propertySchemas , that .propertySchemas ) &&
348
375
Objects .equals (schemaOfAdditionalProperties , that .schemaOfAdditionalProperties ) &&
349
376
Objects .equals (requiredProperties , that .requiredProperties ) &&
@@ -362,7 +389,7 @@ public boolean equals(Object o) {
362
389
363
390
@ Override
364
391
public int hashCode () {
365
- return Objects .hash (super .hashCode (), propertySchemas , propertyNameSchema , additionalProperties ,
392
+ return Objects .hash (super .hashCode (), definitionSchemas , propertySchemas , propertyNameSchema , additionalProperties ,
366
393
schemaOfAdditionalProperties , requiredProperties , minProperties , maxProperties , propertyDependencies ,
367
394
schemaDependencies , requiresObject , patternProperties , oneOrMoreDefaultProperty );
368
395
}
0 commit comments