@@ -12,28 +12,28 @@ public class GenericPropagator {
12
12
// Only static use of this class
13
13
private GenericPropagator () {}
14
14
15
+ private static void setVendorExtension (IJsonSchemaValidationProperties property , String key , Object value ) {
16
+ if (property instanceof CodegenModel ) {
17
+ ((CodegenModel ) property ).vendorExtensions .put (key , value );
18
+ } else if (property instanceof CodegenProperty ) {
19
+ ((CodegenProperty ) property ).vendorExtensions .put (key , value );
20
+ }
21
+ }
22
+
15
23
/**
16
24
* Add the property x-propagated-generic to a model or property, meaning it should be replaced
17
25
* with T directly
18
26
*/
19
27
private static void setPropagatedGeneric (IJsonSchemaValidationProperties property ) {
20
- if (property instanceof CodegenModel ) {
21
- ((CodegenModel ) property ).vendorExtensions .put ("x-propagated-generic" , true );
22
- } else if (property instanceof CodegenProperty ) {
23
- ((CodegenProperty ) property ).vendorExtensions .put ("x-propagated-generic" , true );
24
- }
28
+ setVendorExtension (property , "x-propagated-generic" , true );
25
29
}
26
30
27
31
/**
28
32
* Add the property x-has-child-generic to a model or property, meaning one of its members is
29
33
* generic and it should propagate the T
30
34
*/
31
35
private static void setHasChildGeneric (IJsonSchemaValidationProperties property ) {
32
- if (property instanceof CodegenModel ) {
33
- ((CodegenModel ) property ).vendorExtensions .put ("x-has-child-generic" , true );
34
- } else if (property instanceof CodegenProperty ) {
35
- ((CodegenProperty ) property ).vendorExtensions .put ("x-has-child-generic" , true );
36
- }
36
+ setVendorExtension (property , "x-has-child-generic" , true );
37
37
}
38
38
39
39
/**
@@ -66,7 +66,7 @@ private static CodegenModel propertyToModel(Map<String, CodegenModel> models, Co
66
66
67
67
private static boolean markPropagatedGeneric (IJsonSchemaValidationProperties model ) {
68
68
CodegenProperty items = model .getItems ();
69
- // if the items itself isn't generic, we recurse on it's items and properties until we reach the
69
+ // if items itself isn't generic, we recurse on its items and properties until we reach the
70
70
// end or find a generic property
71
71
if (items != null && ((boolean ) items .vendorExtensions .getOrDefault ("x-is-generic" , false ) || markPropagatedGeneric (items ))) {
72
72
setPropagatedGeneric (model );
@@ -84,7 +84,7 @@ private static boolean markPropagatedGeneric(IJsonSchemaValidationProperties mod
84
84
85
85
private static boolean propagateGenericRecursive (Map <String , CodegenModel > models , IJsonSchemaValidationProperties property ) {
86
86
CodegenProperty items = property .getItems ();
87
- // if the items itself isn't generic, we recurse on it's items and properties (and it's
87
+ // if items itself isn't generic, we recurse on its items and properties (and it's
88
88
// equivalent model if we find one) until we reach the end or find a generic property.
89
89
// We need to check the model too because the tree isn't complete sometime, depending on the ref
90
90
// in the spec, so we get the model with the same name and recurse.
0 commit comments