|
24 | 24 | import java.util.ArrayList; |
25 | 25 | import java.util.Arrays; |
26 | 26 | import java.util.List; |
| 27 | +import org.openapitools.jackson.nullable.JsonNullable; |
27 | 28 |
|
28 | 29 | import com.google.gson.Gson; |
29 | 30 | import com.google.gson.GsonBuilder; |
@@ -330,11 +331,22 @@ public boolean equals(Object o) { |
330 | 331 | Objects.equals(this.additionalProperties, appApiRestV2FunctionsTypesFunction.additionalProperties); |
331 | 332 | } |
332 | 333 |
|
| 334 | + private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) { |
| 335 | + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); |
| 336 | + } |
| 337 | + |
333 | 338 | @Override |
334 | 339 | public int hashCode() { |
335 | 340 | return Objects.hash(functionId, functionName, functionMangledName, functionVaddr, functionSize, debug, embedding3d, embedding1d, additionalProperties); |
336 | 341 | } |
337 | 342 |
|
| 343 | + private static <T> int hashCodeNullable(JsonNullable<T> a) { |
| 344 | + if (a == null) { |
| 345 | + return 1; |
| 346 | + } |
| 347 | + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; |
| 348 | + } |
| 349 | + |
338 | 350 | @Override |
339 | 351 | public String toString() { |
340 | 352 | StringBuilder sb = new StringBuilder(); |
@@ -372,7 +384,7 @@ private String toIndentedString(Object o) { |
372 | 384 | openapiFields = new HashSet<String>(Arrays.asList("function_id", "function_name", "function_mangled_name", "function_vaddr", "function_size", "debug", "embedding_3d", "embedding_1d")); |
373 | 385 |
|
374 | 386 | // a set of required properties/fields (JSON key names) |
375 | | - openapiRequiredFields = new HashSet<String>(Arrays.asList("function_id", "function_name", "function_mangled_name", "function_vaddr", "function_size", "debug", "embedding_3d", "embedding_1d")); |
| 387 | + openapiRequiredFields = new HashSet<String>(Arrays.asList("function_id", "function_name", "function_mangled_name", "function_vaddr", "function_size", "debug")); |
376 | 388 | } |
377 | 389 |
|
378 | 390 | /** |
@@ -401,16 +413,12 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti |
401 | 413 | if (!jsonObj.get("function_mangled_name").isJsonPrimitive()) { |
402 | 414 | throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `function_mangled_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("function_mangled_name").toString())); |
403 | 415 | } |
404 | | - // ensure the required json array is present |
405 | | - if (jsonObj.get("embedding_3d") == null) { |
406 | | - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); |
407 | | - } else if (!jsonObj.get("embedding_3d").isJsonArray()) { |
| 416 | + // ensure the optional json data is an array if present |
| 417 | + if (jsonObj.get("embedding_3d") != null && !jsonObj.get("embedding_3d").isJsonNull() && !jsonObj.get("embedding_3d").isJsonArray()) { |
408 | 418 | throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `embedding_3d` to be an array in the JSON string but got `%s`", jsonObj.get("embedding_3d").toString())); |
409 | 419 | } |
410 | | - // ensure the required json array is present |
411 | | - if (jsonObj.get("embedding_1d") == null) { |
412 | | - throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`"); |
413 | | - } else if (!jsonObj.get("embedding_1d").isJsonArray()) { |
| 420 | + // ensure the optional json data is an array if present |
| 421 | + if (jsonObj.get("embedding_1d") != null && !jsonObj.get("embedding_1d").isJsonNull() && !jsonObj.get("embedding_1d").isJsonArray()) { |
414 | 422 | throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `embedding_1d` to be an array in the JSON string but got `%s`", jsonObj.get("embedding_1d").toString())); |
415 | 423 | } |
416 | 424 | } |
|
0 commit comments