Datasets:
File size: 43,650 Bytes
0e239c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | diff --git a/.github/workflows/maven_release.yml b/.github/workflows/maven_release.yml
index 7efe6ca..cfb2dc3 100644
--- a/.github/workflows/maven_release.yml
+++ b/.github/workflows/maven_release.yml
@@ -15,10 +15,10 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
- java-version: 11
+ java-version: 17
distribution: 'temurin'
- name: Cache and restore Maven packages on master
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
@@ -59,7 +59,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
- java-version: 11
+ java-version: 17
distribution: 'temurin'
server-id: central
server-username: MAVEN_USERNAME
diff --git a/.github/workflows/maven_test.yml b/.github/workflows/maven_test.yml
index 15894f3..d3b05c2 100644
--- a/.github/workflows/maven_test.yml
+++ b/.github/workflows/maven_test.yml
@@ -17,10 +17,10 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- - name: Set up JDK 11
+ - name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
- java-version: 11
+ java-version: 17
distribution: 'temurin'
- name: Cache and restore Maven packages on master
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
diff --git a/pom.xml b/pom.xml
index 58ff5f8..9ac7ef4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,8 @@
<!-- region Dependency Versions -->
<!-- Validator 8+ requires Java 11, Validator 9+ requires Java 17. -->
<hibernate-validator.version>7.0.5.Final</hibernate-validator.version>
- <jackson-bom.version>2.21.1</jackson-bom.version>
+ <jackson2-bom.version>2.21.1</jackson2-bom.version>
+ <jackson3-bom.version>3.0.4</jackson3-bom.version>
<javax-validation-api.version>2.0.1.Final</javax-validation-api.version>
<jakarta-validation-api.version>3.1.1</jakarta-validation-api.version>
<junit.version>5.14.3</junit.version>
@@ -60,10 +61,17 @@
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
- <version>${jackson-bom.version}</version>
+ <version>${jackson2-bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>tools.jackson</groupId>
+ <artifactId>jackson-bom</artifactId>
+ <version>${jackson3-bom.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
@@ -78,6 +86,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>tools.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
@@ -166,6 +180,20 @@
<multiReleaseOutput>true</multiReleaseOutput>
</configuration>
</execution>
+ <execution>
+ <id>compile-java-17</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <release>17</release>
+ <compileSourceRoots>
+ <compileSourceRoot>${project.basedir}/src/main/java17</compileSourceRoot>
+ </compileSourceRoots>
+ <multiReleaseOutput>true</multiReleaseOutput>
+ </configuration>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -233,7 +261,7 @@
</execution>
</executions>
<configuration>
- <source>${java.version}</source>
+ <source>17</source>
<doclint>none</doclint>
<detectJavaApiLink>false</detectJavaApiLink>
<failOnWarnings>false</failOnWarnings>
diff --git a/src/it/jakarta-jar-classpath/pom.xml b/src/it/jakarta-jar-classpath/pom.xml
index 0bf20c8..0cc50f1 100644
--- a/src/it/jakarta-jar-classpath/pom.xml
+++ b/src/it/jakarta-jar-classpath/pom.xml
@@ -25,6 +25,11 @@
<artifactId>jakarta.validation-api</artifactId>
<version>3.1.1</version>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.21.1</version>
+ </dependency>
</dependencies>
<build>
diff --git a/src/it/jakarta-jar-modulepath/pom.xml b/src/it/jakarta-jar-modulepath/pom.xml
index 841640e..73e155b 100644
--- a/src/it/jakarta-jar-modulepath/pom.xml
+++ b/src/it/jakarta-jar-modulepath/pom.xml
@@ -25,6 +25,11 @@
<artifactId>jakarta.validation-api</artifactId>
<version>3.1.1</version>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.21.1</version>
+ </dependency>
</dependencies>
<build>
diff --git a/src/it/jakarta-jlink/pom.xml b/src/it/jakarta-jlink/pom.xml
index 800e441..ccce134 100644
--- a/src/it/jakarta-jlink/pom.xml
+++ b/src/it/jakarta-jlink/pom.xml
@@ -25,6 +25,11 @@
<artifactId>jakarta.validation-api</artifactId>
<version>3.1.1</version>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.21.1</version>
+ </dependency>
</dependencies>
<build>
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanPropertyWriter.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanPropertyWriter.java
similarity index 69%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanPropertyWriter.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanPropertyWriter.java
index 1f8fab6..61f8c1f 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanPropertyWriter.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanPropertyWriter.java
@@ -6,26 +6,26 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.util.NameTransformer;
-public class JsonNullableBeanPropertyWriter extends BeanPropertyWriter
+public class JsonNullableJackson2BeanPropertyWriter extends BeanPropertyWriter
{
private static final long serialVersionUID = 1L;
- protected JsonNullableBeanPropertyWriter(BeanPropertyWriter base) {
+ protected JsonNullableJackson2BeanPropertyWriter(BeanPropertyWriter base) {
super(base);
}
- protected JsonNullableBeanPropertyWriter(BeanPropertyWriter base, PropertyName newName) {
+ protected JsonNullableJackson2BeanPropertyWriter(BeanPropertyWriter base, PropertyName newName) {
super(base, newName);
}
@Override
protected BeanPropertyWriter _new(PropertyName newName) {
- return new JsonNullableBeanPropertyWriter(this, newName);
+ return new JsonNullableJackson2BeanPropertyWriter(this, newName);
}
@Override
public BeanPropertyWriter unwrappingWriter(NameTransformer unwrapper) {
- return new UnwrappingJsonNullableBeanPropertyWriter(this, unwrapper);
+ return new UnwrappingJsonNullableJackson2BeanPropertyWriter(this, unwrapper);
}
@Override
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanSerializerModifier.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanSerializerModifier.java
similarity index 83%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanSerializerModifier.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanSerializerModifier.java
index 75f4a28..6b755c8 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableBeanSerializerModifier.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2BeanSerializerModifier.java
@@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import java.util.List;
-public class JsonNullableBeanSerializerModifier extends BeanSerializerModifier
+public class JsonNullableJackson2BeanSerializerModifier extends BeanSerializerModifier
{
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
@@ -19,7 +19,7 @@ public class JsonNullableBeanSerializerModifier extends BeanSerializerModifier
final BeanPropertyWriter writer = beanProperties.get(i);
JavaType type = writer.getType();
if (type.isTypeOrSubTypeOf(JsonNullable.class)) {
- beanProperties.set(i, new JsonNullableBeanPropertyWriter(writer));
+ beanProperties.set(i, new JsonNullableJackson2BeanPropertyWriter(writer));
}
}
return beanProperties;
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializer.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializer.java
similarity index 85%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializer.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializer.java
index 9ebee24..01eb04a 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializer.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializer.java
@@ -14,7 +14,7 @@ import com.fasterxml.jackson.databind.type.ReferenceType;
import java.io.IOException;
-public class JsonNullableDeserializer extends ReferenceTypeDeserializer<JsonNullable<Object>> {
+public class JsonNullableJackson2Deserializer extends ReferenceTypeDeserializer<JsonNullable<Object>> {
private static final long serialVersionUID = 1L;
@@ -25,8 +25,8 @@ public class JsonNullableDeserializer extends ReferenceTypeDeserializer<JsonNull
/* Life-cycle
/**********************************************************
*/
- public JsonNullableDeserializer(JavaType fullType, ValueInstantiator inst,
- TypeDeserializer typeDeser, JsonDeserializer<?> deser) {
+ public JsonNullableJackson2Deserializer(JavaType fullType, ValueInstantiator inst,
+ TypeDeserializer typeDeser, JsonDeserializer<?> deser) {
super(fullType, inst, typeDeser, deser);
if (fullType instanceof ReferenceType && ((ReferenceType) fullType).getReferencedType() != null) {
this.isStringDeserializer = ((ReferenceType) fullType).getReferencedType().isTypeOrSubTypeOf(String.class);
@@ -52,8 +52,8 @@ public class JsonNullableDeserializer extends ReferenceTypeDeserializer<JsonNull
}
@Override
- public JsonNullableDeserializer withResolved(TypeDeserializer typeDeser, JsonDeserializer<?> valueDeser) {
- return new JsonNullableDeserializer(_fullType, _valueInstantiator,
+ public JsonNullableJackson2Deserializer withResolved(TypeDeserializer typeDeser, JsonDeserializer<?> valueDeser) {
+ return new JsonNullableJackson2Deserializer(_fullType, _valueInstantiator,
typeDeser, valueDeser);
}
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializers.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializers.java
similarity index 82%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializers.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializers.java
index 04764e9..54a5d3b 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableDeserializers.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Deserializers.java
@@ -7,12 +7,12 @@ import com.fasterxml.jackson.databind.deser.Deserializers;
import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
import com.fasterxml.jackson.databind.type.ReferenceType;
-public class JsonNullableDeserializers extends Deserializers.Base {
+public class JsonNullableJackson2Deserializers extends Deserializers.Base {
@Override
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType refType,
DeserializationConfig config, BeanDescription beanDesc,
TypeDeserializer contentTypeDeserializer, JsonDeserializer<?> contentDeserializer) {
- return (refType.hasRawClass(JsonNullable.class)) ? new JsonNullableDeserializer(refType, null, contentTypeDeserializer,contentDeserializer) : null;
+ return (refType.hasRawClass(JsonNullable.class)) ? new JsonNullableJackson2Deserializer(refType, null, contentTypeDeserializer,contentDeserializer) : null;
}
}
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializer.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializer.java
similarity index 73%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializer.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializer.java
index b2957ae..038589e 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializer.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializer.java
@@ -7,7 +7,7 @@ import com.fasterxml.jackson.databind.ser.std.ReferenceTypeSerializer;
import com.fasterxml.jackson.databind.type.ReferenceType;
import com.fasterxml.jackson.databind.util.NameTransformer;
-public class JsonNullableSerializer extends ReferenceTypeSerializer<JsonNullable<?>> {
+public class JsonNullableJackson2Serializer extends ReferenceTypeSerializer<JsonNullable<?>> {
private static final long serialVersionUID = 1L;
@@ -17,14 +17,14 @@ public class JsonNullableSerializer extends ReferenceTypeSerializer<JsonNullable
/**********************************************************
*/
- protected JsonNullableSerializer(ReferenceType fullType, boolean staticTyping,
- TypeSerializer vts, JsonSerializer<Object> ser) {
+ protected JsonNullableJackson2Serializer(ReferenceType fullType, boolean staticTyping,
+ TypeSerializer vts, JsonSerializer<Object> ser) {
super(fullType, staticTyping, vts, ser);
}
- protected JsonNullableSerializer(JsonNullableSerializer base, BeanProperty property,
- TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
- Object suppressableValue)
+ protected JsonNullableJackson2Serializer(JsonNullableJackson2Serializer base, BeanProperty property,
+ TypeSerializer vts, JsonSerializer<?> valueSer, NameTransformer unwrapper,
+ Object suppressableValue)
{
// Keep suppressNulls to false to always serialize JsonNullable[null]
super(base, property, vts, valueSer, unwrapper,
@@ -36,7 +36,7 @@ public class JsonNullableSerializer extends ReferenceTypeSerializer<JsonNullable
TypeSerializer vts, JsonSerializer<?> valueSer,
NameTransformer unwrapper)
{
- return new JsonNullableSerializer(this, prop, vts, valueSer, unwrapper,
+ return new JsonNullableJackson2Serializer(this, prop, vts, valueSer, unwrapper,
_suppressableValue);
}
@@ -44,7 +44,7 @@ public class JsonNullableSerializer extends ReferenceTypeSerializer<JsonNullable
public ReferenceTypeSerializer<JsonNullable<?>> withContentInclusion(Object suppressableValue,
boolean suppressNulls)
{
- return new JsonNullableSerializer(this, _property, _valueTypeSerializer,
+ return new JsonNullableJackson2Serializer(this, _property, _valueTypeSerializer,
_valueSerializer, _unwrapper,
suppressableValue);
}
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializers.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializers.java
similarity index 88%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializers.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializers.java
index db6b1ff..cb92ed0 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableSerializers.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2Serializers.java
@@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.Serializers;
import com.fasterxml.jackson.databind.type.ReferenceType;
-public class JsonNullableSerializers extends Serializers.Base {
+public class JsonNullableJackson2Serializers extends Serializers.Base {
@Override
public JsonSerializer<?> findReferenceSerializer(SerializationConfig config,
@@ -17,7 +17,7 @@ public class JsonNullableSerializers extends Serializers.Base {
if (JsonNullable.class.isAssignableFrom(refType.getRawClass())) {
boolean staticTyping = (contentTypeSerializer == null)
&& config.isEnabled(MapperFeature.USE_STATIC_TYPING);
- return new JsonNullableSerializer(refType, staticTyping,
+ return new JsonNullableJackson2Serializer(refType, staticTyping,
contentTypeSerializer, contentValueSerializer);
}
return null;
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableTypeModifier.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2TypeModifier.java
similarity index 92%
rename from src/main/java/org/openapitools/jackson/nullable/JsonNullableTypeModifier.java
rename to src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2TypeModifier.java
index 7e7663d..0f392b3 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableTypeModifier.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson2TypeModifier.java
@@ -8,7 +8,7 @@ import com.fasterxml.jackson.databind.type.TypeModifier;
import java.lang.reflect.Type;
-public class JsonNullableTypeModifier extends TypeModifier {
+public class JsonNullableJackson2TypeModifier extends TypeModifier {
@Override
public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory)
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3BeanPropertyWriter.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3BeanPropertyWriter.java
new file mode 100644
index 0000000..4c1d88b
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3BeanPropertyWriter.java
@@ -0,0 +1,38 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.databind.PropertyName;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.ser.BeanPropertyWriter;
+import tools.jackson.databind.util.NameTransformer;
+
+public class JsonNullableJackson3BeanPropertyWriter extends BeanPropertyWriter {
+
+ protected JsonNullableJackson3BeanPropertyWriter(BeanPropertyWriter base) {
+ super(base);
+ }
+
+ protected JsonNullableJackson3BeanPropertyWriter(BeanPropertyWriter base, PropertyName newName) {
+ super(base, newName);
+ }
+
+ @Override
+ protected BeanPropertyWriter _new(PropertyName newName) {
+ return new JsonNullableJackson3BeanPropertyWriter(this, newName);
+ }
+
+ @Override
+ public BeanPropertyWriter unwrappingWriter(NameTransformer unwrapper) {
+ return new UnwrappingJsonNullableJackson3BeanPropertyWriter(this, unwrapper);
+ }
+
+ @Override
+ public void serializeAsProperty(Object bean, JsonGenerator jgen, SerializationContext ctxt) throws Exception {
+ Object value = get(bean);
+ if (JsonNullable.undefined().equals(value) || (_nullSerializer == null && value == null)) {
+ return;
+ }
+ super.serializeAsProperty(bean, jgen, ctxt);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializer.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializer.java
new file mode 100644
index 0000000..a01ac80
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializer.java
@@ -0,0 +1,93 @@
+package org.openapitools.jackson.nullable;
+
+
+import tools.jackson.core.JacksonException;
+import tools.jackson.core.JsonParser;
+import tools.jackson.core.JsonToken;
+import tools.jackson.databind.DeserializationConfig;
+import tools.jackson.databind.DeserializationContext;
+import tools.jackson.databind.JavaType;
+import tools.jackson.databind.ValueDeserializer;
+import tools.jackson.databind.deser.ValueInstantiator;
+import tools.jackson.databind.deser.std.ReferenceTypeDeserializer;
+import tools.jackson.databind.jsontype.TypeDeserializer;
+import tools.jackson.databind.type.ReferenceType;
+
+public class JsonNullableJackson3Deserializer extends ReferenceTypeDeserializer<JsonNullable<Object>> {
+
+
+ private boolean isStringDeserializer = false;
+
+ /*
+ /**********************************************************
+ /* Life-cycle
+ /**********************************************************
+ */
+ public JsonNullableJackson3Deserializer(JavaType fullType, ValueInstantiator inst,
+ TypeDeserializer typeDeser, ValueDeserializer<?> deser) {
+ super(fullType, inst, typeDeser, deser);
+ if (fullType instanceof ReferenceType && ((ReferenceType) fullType).getReferencedType() != null) {
+ this.isStringDeserializer = ((ReferenceType) fullType).getReferencedType().isTypeOrSubTypeOf(String.class);
+ }
+ }
+
+ /*
+ /**********************************************************
+ /* Abstract method implementations
+ /**********************************************************
+ */
+
+ @Override
+ public JsonNullable<Object> deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException {
+ JsonToken t = p.currentToken();
+ if (t == JsonToken.VALUE_STRING && !isStringDeserializer) {
+ String str = p.getString().trim();
+ if (str.isEmpty()) {
+ return JsonNullable.undefined();
+ }
+ }
+ return super.deserialize(p, ctxt);
+ }
+
+ @Override
+ protected ReferenceTypeDeserializer<JsonNullable<Object>> withResolved(TypeDeserializer typeDeser, ValueDeserializer<?> valueDeser) {
+ return new JsonNullableJackson3Deserializer(_fullType, _valueInstantiator,
+ typeDeser, valueDeser);
+ }
+
+ @Override
+ public Object getAbsentValue(DeserializationContext ctxt) {
+ return JsonNullable.undefined();
+ }
+
+ @Override
+ public JsonNullable<Object> getNullValue(DeserializationContext ctxt) {
+ return JsonNullable.of(null);
+ }
+
+ @Override
+ public Object getEmptyValue(DeserializationContext ctxt) {
+ return JsonNullable.undefined();
+ }
+
+ @Override
+ public JsonNullable<Object> referenceValue(Object contents) {
+ return JsonNullable.of(contents);
+ }
+
+ @Override
+ public Object getReferenced(JsonNullable<Object> reference) {
+ return reference.get();
+ }
+
+ @Override
+ public JsonNullable<Object> updateReference(JsonNullable<Object> reference, Object contents) {
+ return JsonNullable.of(contents);
+ }
+
+ @Override
+ public Boolean supportsUpdate(DeserializationConfig config) {
+ // yes; regardless of value deserializer reference itself may be updated
+ return Boolean.TRUE;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializers.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializers.java
new file mode 100644
index 0000000..7ef853c
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Deserializers.java
@@ -0,0 +1,23 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.databind.DeserializationConfig;
+import tools.jackson.databind.ValueDeserializer;
+import tools.jackson.databind.BeanDescription.Supplier;
+import tools.jackson.databind.deser.Deserializers;
+import tools.jackson.databind.jsontype.TypeDeserializer;
+import tools.jackson.databind.type.ReferenceType;
+
+public class JsonNullableJackson3Deserializers extends Deserializers.Base {
+
+ @Override
+ public ValueDeserializer<?> findReferenceDeserializer(ReferenceType refType,
+ DeserializationConfig config, Supplier beanDescRef,
+ TypeDeserializer contentTypeDeserializer, ValueDeserializer<?> contentDeserializer) {
+ return (refType.hasRawClass(JsonNullable.class)) ? new JsonNullableJackson3Deserializer(refType, null, contentTypeDeserializer,contentDeserializer) : null;
+ }
+
+ @Override
+ public boolean hasDeserializerFor(DeserializationConfig config, Class<?> valueType) {
+ return JsonNullable.class.equals(valueType);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Module.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Module.java
new file mode 100644
index 0000000..e9abf49
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Module.java
@@ -0,0 +1,39 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.core.Version;
+import tools.jackson.core.json.PackageVersion;
+import tools.jackson.databind.JacksonModule;
+
+public class JsonNullableJackson3Module extends JacksonModule {
+
+ private final String NAME = "JsonNullableModule";
+
+ @Override
+ public void setupModule(SetupContext context) {
+ context.addSerializers(new JsonNullableJackson3Serializers());
+ context.addDeserializers(new JsonNullableJackson3Deserializers());
+ // Modify type info for JsonNullable
+ context.addTypeModifier(new JsonNullableJackson3TypeModifier());
+ context.addSerializerModifier(new JsonNullableJackson3ValueSerializerModifier());
+ }
+
+ @Override
+ public Version version() {
+ return PackageVersion.VERSION;
+ }
+
+ @Override
+ public int hashCode() {
+ return NAME.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return this == o;
+ }
+
+ @Override
+ public String getModuleName() {
+ return NAME;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializer.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializer.java
new file mode 100644
index 0000000..5c91ac2
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializer.java
@@ -0,0 +1,72 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.databind.BeanProperty;
+import tools.jackson.databind.ValueSerializer;
+import tools.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.databind.ser.std.ReferenceTypeSerializer;
+import tools.jackson.databind.type.ReferenceType;
+import tools.jackson.databind.util.NameTransformer;
+
+public class JsonNullableJackson3Serializer extends ReferenceTypeSerializer<JsonNullable<?>> {
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ /**********************************************************
+ /* Constructors, factory methods
+ /**********************************************************
+ */
+
+ protected JsonNullableJackson3Serializer(ReferenceType fullType, boolean staticTyping,
+ TypeSerializer vts, ValueSerializer<Object> ser) {
+ super(fullType, staticTyping, vts, ser);
+ }
+
+ protected JsonNullableJackson3Serializer(JsonNullableJackson3Serializer base, BeanProperty property,
+ TypeSerializer vts, ValueSerializer<?> valueSer, NameTransformer unwrapper,
+ Object suppressableValue)
+ {
+ // Keep suppressNulls to false to always serialize JsonNullable[null]
+ super(base, property, vts, valueSer, unwrapper,
+ suppressableValue, false);
+ }
+
+ @Override
+ protected ReferenceTypeSerializer<JsonNullable<?>> withResolved(BeanProperty prop,
+ TypeSerializer vts, ValueSerializer<?> valueSer,
+ NameTransformer unwrapper)
+ {
+ return new JsonNullableJackson3Serializer(this, prop, vts, valueSer, unwrapper,
+ _suppressableValue);
+ }
+
+ @Override
+ public ReferenceTypeSerializer<JsonNullable<?>> withContentInclusion(Object suppressableValue,
+ boolean suppressNulls)
+ {
+ return new JsonNullableJackson3Serializer(this, _property, _valueTypeSerializer,
+ _valueSerializer, _unwrapper,
+ suppressableValue);
+ }
+
+ /*
+ /**********************************************************
+ /* Abstract method impls
+ /**********************************************************
+ */
+
+ @Override
+ protected boolean _isValuePresent(JsonNullable<?> value) {
+ return value.isPresent();
+ }
+
+ @Override
+ protected Object _getReferenced(JsonNullable<?> value) {
+ return value.get();
+ }
+
+ @Override
+ protected Object _getReferencedIfPresent(JsonNullable<?> value) {
+ return value.isPresent() ? value.get() : null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializers.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializers.java
new file mode 100644
index 0000000..fdf826c
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3Serializers.java
@@ -0,0 +1,27 @@
+package org.openapitools.jackson.nullable;
+
+
+import com.fasterxml.jackson.annotation.JsonFormat.Value;
+
+import tools.jackson.databind.MapperFeature;
+import tools.jackson.databind.SerializationConfig;
+import tools.jackson.databind.ValueSerializer;
+import tools.jackson.databind.BeanDescription.Supplier;
+import tools.jackson.databind.jsontype.TypeSerializer;
+import tools.jackson.databind.ser.Serializers;
+import tools.jackson.databind.type.ReferenceType;
+
+public class JsonNullableJackson3Serializers extends Serializers.Base {
+ @Override
+ public ValueSerializer<?> findReferenceSerializer(SerializationConfig config,
+ ReferenceType refType, Supplier beanDescRef, Value formatOverrides,
+ TypeSerializer contentTypeSerializer, ValueSerializer<Object> contentValueSerializer) {
+ if (JsonNullable.class.isAssignableFrom(refType.getRawClass())) {
+ boolean staticTyping = (contentTypeSerializer == null)
+ && config.isEnabled(MapperFeature.USE_STATIC_TYPING);
+ return new JsonNullableJackson3Serializer(refType, staticTyping,
+ contentTypeSerializer, contentValueSerializer);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3TypeModifier.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3TypeModifier.java
new file mode 100644
index 0000000..8a4a63c
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3TypeModifier.java
@@ -0,0 +1,30 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.databind.JavaType;
+import tools.jackson.databind.type.ReferenceType;
+import tools.jackson.databind.type.TypeBindings;
+import tools.jackson.databind.type.TypeFactory;
+import tools.jackson.databind.type.TypeModifier;
+
+import java.lang.reflect.Type;
+
+public class JsonNullableJackson3TypeModifier extends TypeModifier {
+
+ @Override
+ public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory)
+ {
+ if (type.isReferenceType() || type.isContainerType()) {
+ return type;
+ }
+ final Class<?> raw = type.getRawClass();
+
+ JavaType refType;
+
+ if (raw == JsonNullable.class) {
+ refType = type.containedTypeOrUnknown(0);
+ } else {
+ return type;
+ }
+ return ReferenceType.upgradeFrom(type, refType);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3ValueSerializerModifier.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3ValueSerializerModifier.java
new file mode 100644
index 0000000..c20b1fb
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableJackson3ValueSerializerModifier.java
@@ -0,0 +1,27 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.databind.JavaType;
+import tools.jackson.databind.SerializationConfig;
+import tools.jackson.databind.BeanDescription.Supplier;
+import tools.jackson.databind.ser.BeanPropertyWriter;
+import tools.jackson.databind.ser.ValueSerializerModifier;
+
+import java.util.List;
+
+public class JsonNullableJackson3ValueSerializerModifier extends ValueSerializerModifier
+{
+ @Override
+ public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
+ Supplier beanDesc,
+ List<BeanPropertyWriter> beanProperties)
+ {
+ for (int i = 0; i < beanProperties.size(); ++i) {
+ final BeanPropertyWriter writer = beanProperties.get(i);
+ JavaType type = writer.getType();
+ if (type.isTypeOrSubTypeOf(JsonNullable.class)) {
+ beanProperties.set(i, new JsonNullableJackson3BeanPropertyWriter(writer));
+ }
+ }
+ return beanProperties;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/openapitools/jackson/nullable/JsonNullableModule.java b/src/main/java/org/openapitools/jackson/nullable/JsonNullableModule.java
index 2101f83..0b9fdd0 100644
--- a/src/main/java/org/openapitools/jackson/nullable/JsonNullableModule.java
+++ b/src/main/java/org/openapitools/jackson/nullable/JsonNullableModule.java
@@ -10,11 +10,11 @@ public class JsonNullableModule extends Module {
@Override
public void setupModule(SetupContext context) {
- context.addSerializers(new JsonNullableSerializers());
- context.addDeserializers(new JsonNullableDeserializers());
+ context.addSerializers(new JsonNullableJackson2Serializers());
+ context.addDeserializers(new JsonNullableJackson2Deserializers());
// Modify type info for JsonNullable
- context.addTypeModifier(new JsonNullableTypeModifier());
- context.addBeanSerializerModifier(new JsonNullableBeanSerializerModifier());
+ context.addTypeModifier(new JsonNullableJackson2TypeModifier());
+ context.addBeanSerializerModifier(new JsonNullableJackson2BeanSerializerModifier());
}
@Override
diff --git a/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableBeanPropertyWriter.java b/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson2BeanPropertyWriter.java
similarity index 63%
rename from src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableBeanPropertyWriter.java
rename to src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson2BeanPropertyWriter.java
index a9d1052..5235138 100644
--- a/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableBeanPropertyWriter.java
+++ b/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson2BeanPropertyWriter.java
@@ -7,24 +7,24 @@ import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.UnwrappingBeanPropertyWriter;
import com.fasterxml.jackson.databind.util.NameTransformer;
-public class UnwrappingJsonNullableBeanPropertyWriter extends UnwrappingBeanPropertyWriter
+public class UnwrappingJsonNullableJackson2BeanPropertyWriter extends UnwrappingBeanPropertyWriter
{
private static final long serialVersionUID = 1L;
- public UnwrappingJsonNullableBeanPropertyWriter(BeanPropertyWriter base,
- NameTransformer transformer) {
+ public UnwrappingJsonNullableJackson2BeanPropertyWriter(BeanPropertyWriter base,
+ NameTransformer transformer) {
super(base, transformer);
}
- protected UnwrappingJsonNullableBeanPropertyWriter(UnwrappingBeanPropertyWriter base,
- NameTransformer transformer, SerializedString name) {
+ protected UnwrappingJsonNullableJackson2BeanPropertyWriter(UnwrappingBeanPropertyWriter base,
+ NameTransformer transformer, SerializedString name) {
super(base, transformer, name);
}
@Override
protected UnwrappingBeanPropertyWriter _new(NameTransformer transformer, SerializedString newName)
{
- return new UnwrappingJsonNullableBeanPropertyWriter(this, transformer, newName);
+ return new UnwrappingJsonNullableJackson2BeanPropertyWriter(this, transformer, newName);
}
@Override
diff --git a/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson3BeanPropertyWriter.java b/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson3BeanPropertyWriter.java
new file mode 100644
index 0000000..275ed02
--- /dev/null
+++ b/src/main/java/org/openapitools/jackson/nullable/UnwrappingJsonNullableJackson3BeanPropertyWriter.java
@@ -0,0 +1,36 @@
+package org.openapitools.jackson.nullable;
+
+import tools.jackson.core.JsonGenerator;
+import tools.jackson.core.io.SerializedString;
+import tools.jackson.databind.SerializationContext;
+import tools.jackson.databind.ser.BeanPropertyWriter;
+import tools.jackson.databind.ser.bean.UnwrappingBeanPropertyWriter;
+import tools.jackson.databind.util.NameTransformer;
+
+public class UnwrappingJsonNullableJackson3BeanPropertyWriter extends UnwrappingBeanPropertyWriter {
+
+
+ public UnwrappingJsonNullableJackson3BeanPropertyWriter(BeanPropertyWriter base,
+ NameTransformer transformer) {
+ super(base, transformer);
+ }
+
+ protected UnwrappingJsonNullableJackson3BeanPropertyWriter(UnwrappingBeanPropertyWriter base,
+ NameTransformer transformer, SerializedString name) {
+ super(base, transformer, name);
+ }
+
+ @Override
+ protected UnwrappingBeanPropertyWriter _new(NameTransformer transformer, SerializedString newName) {
+ return new UnwrappingJsonNullableJackson3BeanPropertyWriter(this, transformer, newName);
+ }
+
+ @Override
+ public void serializeAsProperty(Object bean, JsonGenerator gen, SerializationContext prov) throws Exception {
+ Object value = get(bean);
+ if (JsonNullable.undefined().equals(value) || (_nullSerializer == null && value == null)) {
+ return;
+ }
+ super.serializeAsProperty(bean, gen, prov);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java17/module-info.java b/src/main/java17/module-info.java
new file mode 100644
index 0000000..0cb572d
--- /dev/null
+++ b/src/main/java17/module-info.java
@@ -0,0 +1,15 @@
+module org.openapitools.jackson.nullable {
+ requires static com.fasterxml.jackson.databind;
+ requires static tools.jackson.databind;
+ requires static jakarta.validation;
+ requires static java.validation;
+
+ exports org.openapitools.jackson.nullable;
+
+ // These service providers for optional dependencies can be added, if baseline is 25+ or alternative implementations can be dropped
+ // see https://github.com/OpenAPITools/jackson-databind-nullable/issues/100
+ // provides com.fasterxml.jackson.databind.Module with org.openapitools.jackson.nullable.JsonNullableModule;
+ // provides tools.jackson.databind.JacksonModule with org.openapitools.jackson.nullable.JsonNullableJackson3Module;
+ // provides javax.validation.valueextraction.ValueExtractor with org.openapitools.jackson.nullable.JsonNullableValueExtractor;
+ // provides jakarta.validation.valueextraction.ValueExtractor with org.openapitools.jackson.nullable.JsonNullableJakartaValueExtractor;
+}
diff --git a/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule b/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule
new file mode 100644
index 0000000..86f8499
--- /dev/null
+++ b/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule
@@ -0,0 +1 @@
+org.openapitools.jackson.nullable.JsonNullableJackson3Module
\ No newline at end of file
|