Skip to content

Commit b3cd596

Browse files
committed
review
1 parent 989b677 commit b3cd596

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

generators/src/main/java/com/algolia/codegen/GenericPropagator.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ public class GenericPropagator {
1212
// Only static use of this class
1313
private GenericPropagator() {}
1414

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+
1523
/**
1624
* Add the property x-propagated-generic to a model or property, meaning it should be replaced
1725
* with T directly
1826
*/
1927
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);
2529
}
2630

2731
/**
2832
* Add the property x-has-child-generic to a model or property, meaning one of its members is
2933
* generic and it should propagate the T
3034
*/
3135
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);
3737
}
3838

3939
/**
@@ -66,7 +66,7 @@ private static CodegenModel propertyToModel(Map<String, CodegenModel> models, Co
6666

6767
private static boolean markPropagatedGeneric(IJsonSchemaValidationProperties model) {
6868
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
7070
// end or find a generic property
7171
if (items != null && ((boolean) items.vendorExtensions.getOrDefault("x-is-generic", false) || markPropagatedGeneric(items))) {
7272
setPropagatedGeneric(model);
@@ -84,7 +84,7 @@ private static boolean markPropagatedGeneric(IJsonSchemaValidationProperties mod
8484

8585
private static boolean propagateGenericRecursive(Map<String, CodegenModel> models, IJsonSchemaValidationProperties property) {
8686
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
8888
// equivalent model if we find one) until we reach the end or find a generic property.
8989
// We need to check the model too because the tree isn't complete sometime, depending on the ref
9090
// in the spec, so we get the model with the same name and recurse.

0 commit comments

Comments
 (0)