Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package jackson-annotations for openSUSE:Factory checked in at 2024-03-11 15:34:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/jackson-annotations (Old) and /work/SRC/openSUSE:Factory/.jackson-annotations.new.1770 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "jackson-annotations" Mon Mar 11 15:34:04 2024 rev:12 rq:1156777 version:2.16.1 Changes: -------- --- /work/SRC/openSUSE:Factory/jackson-annotations/jackson-annotations.changes 2023-08-23 14:57:49.538012825 +0200 +++ /work/SRC/openSUSE:Factory/.jackson-annotations.new.1770/jackson-annotations.changes 2024-03-11 15:41:43.659643594 +0100 @@ -1,0 +2,11 @@ +Fri Mar 8 08:33:47 UTC 2024 - Gus Kenion <gken...@suse.com> + +- Update to 2.16.1 + * no substantial changes from 2.16.0 + * 2.16.0 (15-Nov-2023) + + #223: Add new OptBoolean valued property in @JsonTypeInfo to + allow per-type configuration of strict type id handling + + #229: Add JsonTypeInfo.Value object (backport from 3.0) + + #234: Add new JsonTypeInfo.Id.SIMPLE_NAME + +------------------------------------------------------------------- Old: ---- jackson-annotations-2.15.2.tar.gz New: ---- jackson-annotations-2.16.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ jackson-annotations.spec ++++++ --- /var/tmp/diff_new_pack.V1xVC5/_old 2024-03-11 15:41:44.123660698 +0100 +++ /var/tmp/diff_new_pack.V1xVC5/_new 2024-03-11 15:41:44.127660845 +0100 @@ -1,7 +1,7 @@ # # spec file for package jackson-annotations # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: jackson-annotations -Version: 2.15.2 +Version: 2.16.1 Release: 0 Summary: Core annotations for Jackson data processor License: Apache-2.0 @@ -59,7 +59,7 @@ install -pm 0644 target/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar install -dm 0755 %{buildroot}%{_mavenpomdir} -%mvn_install_pom pom.xml %{buildroot}%{_mavenpomdir}/%{name}.pom +%{mvn_install_pom} pom.xml %{buildroot}%{_mavenpomdir}/%{name}.pom %add_maven_depmap %{name}.pom %{name}.jar install -dm 0755 %{buildroot}%{_javadocdir} ++++++ jackson-annotations-2.15.2.tar.gz -> jackson-annotations-2.16.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/.github/dependabot.yml new/jackson-annotations-jackson-annotations-2.16.1/.github/dependabot.yml --- old/jackson-annotations-jackson-annotations-2.15.2/.github/dependabot.yml 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/.github/dependabot.yml 2023-12-24 05:01:46.000000000 +0100 @@ -4,3 +4,7 @@ directory: "/" schedule: interval: "weekly" + groups: + github-actions: + patterns: + - "*" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/.github/workflows/main.yml new/jackson-annotations-jackson-annotations-2.16.1/.github/workflows/main.yml --- old/jackson-annotations-jackson-annotations-2.15.2/.github/workflows/main.yml 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/.github/workflows/main.yml 2023-12-24 05:01:46.000000000 +0100 @@ -4,7 +4,7 @@ branches: - master - "3.0" - - "2.15" + - "2.16" paths-ignore: - "README.md" - "release-notes/*" @@ -12,7 +12,7 @@ branches: - master - "3.0" - - "2.15" + - "2.16" paths-ignore: - "README.md" - "release-notes/*" @@ -31,9 +31,9 @@ env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 with: distribution: 'temurin' java-version: ${{ matrix.java_version }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/.gitignore new/jackson-annotations-jackson-annotations-2.16.1/.gitignore --- old/jackson-annotations-jackson-annotations-2.15.2/.gitignore 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/.gitignore 2023-12-24 05:01:46.000000000 +0100 @@ -8,7 +8,8 @@ .DS_Store # building -target +/target +.mvn/wrapper/maven-wrapper.jar # Eclipse .classpath Binary files old/jackson-annotations-jackson-annotations-2.15.2/.mvn/wrapper/maven-wrapper.jar and new/jackson-annotations-jackson-annotations-2.16.1/.mvn/wrapper/maven-wrapper.jar differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/.mvn/wrapper/maven-wrapper.properties new/jackson-annotations-jackson-annotations-2.16.1/.mvn/wrapper/maven-wrapper.properties --- old/jackson-annotations-jackson-annotations-2.15.2/.mvn/wrapper/maven-wrapper.properties 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/.mvn/wrapper/maven-wrapper.properties 2023-12-24 05:01:46.000000000 +0100 @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/README.md new/jackson-annotations-jackson-annotations-2.16.1/README.md --- old/jackson-annotations-jackson-annotations-2.15.2/README.md 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/README.md 2023-12-24 05:01:46.000000000 +0100 @@ -18,6 +18,7 @@ [](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.core/jackson-annotations) [](http://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations) [](https://tidelift.com/subscription/pkg/maven-com-fasterxml-jackson-core-jackson-annotations?utm_source=maven-com-fasterxml-jackson-core-jackson-annotations&utm_medium=referral&utm_campaign=readme) +[](https://securityscorecards.dev/viewer/?uri=github.com/FasterXML/jackson-annotations) ----- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/pom.xml new/jackson-annotations-jackson-annotations-2.16.1/pom.xml --- old/jackson-annotations-jackson-annotations-2.15.2/pom.xml 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/pom.xml 2023-12-24 05:01:46.000000000 +0100 @@ -10,13 +10,13 @@ <groupId>com.fasterxml.jackson</groupId> <!-- this is one of few Jackson modules that depends on parent and NOT jackson-bom --> <artifactId>jackson-parent</artifactId> - <version>2.15</version> + <version>2.16</version> </parent> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <name>Jackson-annotations</name> - <version>2.15.2</version> + <version>2.16.1</version> <packaging>jar</packaging> <description>Core annotations used for value types, used by Jackson data binding package. </description> @@ -34,7 +34,7 @@ <connection>scm:git:g...@github.com:FasterXML/jackson-annotations.git</connection> <developerConnection>scm:git:g...@github.com:FasterXML/jackson-annotations.git</developerConnection> <url>https://github.com/FasterXML/jackson-annotations</url> - <tag>jackson-annotations-2.15.2</tag> + <tag>jackson-annotations-2.16.1</tag> </scm> <properties> @@ -50,7 +50,7 @@ <osgi.export>com.fasterxml.jackson.annotation.*;version=${project.version}</osgi.export> <!-- for Reproducible Builds --> - <project.build.outputTimestamp>2023-05-30T20:33:15Z</project.build.outputTimestamp> + <project.build.outputTimestamp>2023-12-24T04:01:38Z</project.build.outputTimestamp> </properties> <dependencies> @@ -107,7 +107,7 @@ <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> - <version>1.6.8</version> + <version>1.6.13</version> <extensions>true</extensions> <configuration> <serverId>sonatype-nexus-staging</serverId> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/release-notes/VERSION-2.x new/jackson-annotations-jackson-annotations-2.16.1/release-notes/VERSION-2.x --- old/jackson-annotations-jackson-annotations-2.15.2/release-notes/VERSION-2.x 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/release-notes/VERSION-2.x 2023-12-24 05:01:46.000000000 +0100 @@ -11,6 +11,16 @@ === Releases === ------------------------------------------------------------------------ +2.16.0 (15-Nov-2023) + +#223: Add new `OptBoolean` valued property in `@JsonTypeInfo` to allow + per-type configuration of strict type id handling + (contributed by Joo-Hyuk K) +#229: Add `JsonTypeInfo.Value` object (backport from 3.0) + (contributed by Joo-Hyuk K) +#234: Add new `JsonTypeInfo.Id.SIMPLE_NAME` + (contributed by Joo-Hyuk K) + 2.15.0 (23-Apr-2023) #211: Add `JsonFormat.Feature`s: READ_UNKNOWN_ENUM_VALUES_AS_NULL, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java new/jackson-annotations-jackson-annotations-2.16.1/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java --- old/jackson-annotations-jackson-annotations-2.15.2/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java 2023-12-24 05:01:46.000000000 +0100 @@ -103,6 +103,14 @@ * State of this property is exposed via introspection, and its * value is typically used by Schema generators, such as one for * JSON Schema. + *<p> + * Also note that the required value must come <b>directly</b> from the + * input source (e.g., JSON) and not from secondary sources, such as + * defaulting logic or absent value providers. + * If secondary sources are expected to supply the value, + * this property should be set to {@code false}. This is important because + * validation of {@code required} properties occurs before the application of + * secondary sources. * * @since 2.0 */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java new/jackson-annotations-jackson-annotations-2.16.1/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java --- old/jackson-annotations-jackson-annotations-2.15.2/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java 2023-05-30 22:33:22.000000000 +0200 +++ new/jackson-annotations-jackson-annotations-2.16.1/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java 2023-12-24 05:01:46.000000000 +0100 @@ -120,14 +120,33 @@ NAME("@type"), /** + * Means that the simple name of the Java class, equivalent to the value returned by {@link Class#getSimpleName()}, + * is used as the default type identifier, unless explicit name is specified by annotation {@link JsonTypeName}. + *<br> + * For instance: + * <ul> + * <li>For a class "com.example.MyClass", only "MyClass" is used.</li> + * <li>For an inner class "com.example.MyClass$Inner", only "Inner" is used.</li> + * </ul> + * <b>Note:</b> This approach reduces verbosity but requires the simple names to be unique + * to avoid conflicts. If multiple classes share the same simple name, <b>the last declared one</b> + * will be used. This approach should be used with careful consideration of your type hierarchy. + * + * @since 2.16 + */ + SIMPLE_NAME("@type"), + + /** * Means that no serialized typing-property is used. Types are <i>deduced</i> based * on the fields available. Deduction is limited to the <i>names</i> of fields * (not their values or, consequently, any nested descendants). Exceptions will be * thrown if not enough unique information is present to select a single subtype. * <br>If deduction is being used annotation properties {@code visible}, * {@code property} and {@code include} are ignored. + * <p> + * On serialization, no type ID is written, and only regular properties are included. * - * @since 2.12.0. + * @since 2.12 */ DEDUCTION(null), @@ -213,7 +232,7 @@ * This mostly matters with respect to output order; this choice is the only * way to ensure specific placement of type id during serialization. * - * @since 2.3.0 but databind <b>only since 2.5.0</b>. + * @since 2.3 but databind <b>only since 2.5</b>. */ EXISTING_PROPERTY ; @@ -303,18 +322,6 @@ */ public boolean visible() default false; - // 19-Dec-2014, tatu: Was hoping to implement for 2.5, but didn't quite make it. - // Hope for better luck with 2.8 or later - /** - * Property that defines whether type serializer is allowed to omit writing - * of type id, in case that value written has type same as {@link #defaultImpl()}. - * If true, omission is allowed (although writer may or may not be able to do that); - * if false, type id should always be written still. - * - * @since 2.5 - public boolean skipWritingDefault() default false; - /* - /* /********************************************************** /* Helper classes @@ -330,5 +337,214 @@ * if such behavior is needed; this is rarely necessary. */ @Deprecated - public abstract static class None { } + public abstract static class None {} + + /** + * Specifies whether the type ID should be strictly required during polymorphic + * deserialization of its subtypes. + * <p> + * If set to {@link OptBoolean#TRUE}, an {@code InvalidTypeIdException} will + * be thrown if no type information is provided. + * If set to {@link OptBoolean#FALSE}, deserialization may proceed without + * type information if the subtype is a legitimate target (non-abstract). + * If set to {@link OptBoolean#DEFAULT}, the global configuration of + * {@code MapperFeature#REQUIRE_TYPE_ID_FOR_SUBTYPES} is used for type ID handling. + * <p> + * NOTE: This setting is specific to this type and will <strong>always override</strong> + * the global configuration of {@code MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES}. + * + * @since 2.16 + */ + public OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; + + /* + /********************************************************************** + /* Value class used to enclose information, allow for + /* merging of layered configuration settings. + /********************************************************************** + */ + + public static class Value + implements JacksonAnnotationValue<JsonTypeInfo>, + java.io.Serializable + { + private static final long serialVersionUID = 1L; + + // should not really be needed usually but make sure defalts to `NONE`; other + // values of less interest + protected final static Value EMPTY = new Value(Id.NONE, As.PROPERTY, null, null, false, null); + + protected final Id _idType; + protected final As _inclusionType; + protected final String _propertyName; + + protected final Class<?> _defaultImpl; + protected final boolean _idVisible; + protected final Boolean _requireTypeIdForSubtypes; + + /* + /********************************************************************** + /* Construction + /********************************************************************** + */ + + protected Value(Id idType, As inclusionType, + String propertyName, Class<?> defaultImpl, boolean idVisible, Boolean requireTypeIdForSubtypes) + { + _defaultImpl = defaultImpl; + _idType = idType; + _inclusionType = inclusionType; + _propertyName = propertyName; + _idVisible = idVisible; + _requireTypeIdForSubtypes = requireTypeIdForSubtypes; + } + + public static Value construct(Id idType, As inclusionType, + String propertyName, Class<?> defaultImpl, boolean idVisible, Boolean requireTypeIdForSubtypes) + { + // couple of overrides we need to apply here. First: if no propertyName specified, + // use Id-specific property name + if ((propertyName == null) || propertyName.isEmpty()) { + if (idType != null) { + propertyName = idType.getDefaultPropertyName(); + } else { + propertyName = ""; + } + } + // Although we can not do much here for special handling of `Void`, we can convert + // annotation types as `null` (== no default implementation) + if ((defaultImpl == null) || defaultImpl.isAnnotation()) { + defaultImpl = null; + } + return new Value(idType, inclusionType, propertyName, defaultImpl, idVisible, requireTypeIdForSubtypes); + } + + public static Value from(JsonTypeInfo src) { + if (src == null) { + return null; + } + return construct(src.use(), src.include(), + src.property(), src.defaultImpl(), src.visible(), src.requireTypeIdForSubtypes().asBoolean()); + } + + /* + /********************************************************************** + /* Mutators + /********************************************************************** + */ + + public Value withDefaultImpl(Class<?> impl) { + return (impl == _defaultImpl) ? this : + new Value(_idType, _inclusionType, _propertyName, impl, _idVisible, _requireTypeIdForSubtypes); + } + + public Value withIdType(Id idType) { + return (idType == _idType) ? this : + new Value(idType, _inclusionType, _propertyName, _defaultImpl, _idVisible, _requireTypeIdForSubtypes); + } + + public Value withInclusionType(As inclusionType) { + return (inclusionType == _inclusionType) ? this : + new Value(_idType, inclusionType, _propertyName, _defaultImpl, _idVisible, _requireTypeIdForSubtypes); + } + + public Value withPropertyName(String propName) { + return (propName == _propertyName) ? this : + new Value(_idType, _inclusionType, propName, _defaultImpl, _idVisible, _requireTypeIdForSubtypes); + } + + public Value withIdVisible(boolean visible) { + return (visible == _idVisible) ? this : + new Value(_idType, _inclusionType, _propertyName, _defaultImpl, visible, _requireTypeIdForSubtypes); + } + + public Value withRequireTypeIdForSubtypes(Boolean requireTypeIdForSubtypes) { + return (_requireTypeIdForSubtypes == requireTypeIdForSubtypes) ? this : + new Value(_idType, _inclusionType, _propertyName, _defaultImpl, _idVisible, requireTypeIdForSubtypes); + } + + /* + /********************************************************************** + /* Simple accessors + /********************************************************************** + */ + + @Override + public Class<JsonTypeInfo> valueFor() { + return JsonTypeInfo.class; + } + + public Class<?> getDefaultImpl() { return _defaultImpl; } + public Id getIdType() { return _idType; } + public As getInclusionType() { return _inclusionType; } + public String getPropertyName() { return _propertyName; } + public boolean getIdVisible() { return _idVisible; } + public Boolean getRequireTypeIdForSubtypes() { return _requireTypeIdForSubtypes; } + + /** + * Static helper method for simple(r) checking of whether there's a Value instance + * that indicates that polymorphic handling is (to be) enabled. + */ + public static boolean isEnabled(JsonTypeInfo.Value v) { + return (v != null) && + (v._idType != null) && (v._idType != Id.NONE); + } + + /* + /********************************************************************** + /* Standard methods + /********************************************************************** + */ + + @Override + public String toString() { + return String.format("JsonTypeInfo.Value(idType=%s,includeAs=%s,propertyName=%s,defaultImpl=%s,idVisible=%s" + + ",requireTypeIdForSubtypes=%s)", + _idType, _inclusionType, _propertyName, + ((_defaultImpl == null) ? "NULL" : _defaultImpl.getName()), + _idVisible, _requireTypeIdForSubtypes); + } + + @Override + public int hashCode() { + int hashCode = 1; + hashCode = 31 * hashCode + (_idType != null ? _idType.hashCode() : 0); + hashCode = 31 * hashCode + (_inclusionType != null ? _inclusionType.hashCode() : 0); + hashCode = 31 * hashCode + (_propertyName != null ? _propertyName.hashCode() : 0); + hashCode = 31 * hashCode + (_defaultImpl != null ? _defaultImpl.hashCode() : 0); + hashCode = 31 * hashCode + (_requireTypeIdForSubtypes ? 11 : -17); + hashCode = 31 * hashCode + (_idVisible ? 11 : -17); + return hashCode; + } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if (o == null) return false; + return (o.getClass() == getClass()) + && _equals(this, (Value) o); + } + + private static boolean _equals(Value a, Value b) + { + return (a._idType == b._idType) + && (a._inclusionType == b._inclusionType) + && (a._defaultImpl == b._defaultImpl) + && (a._idVisible == b._idVisible) + && _equal(a._propertyName, b._propertyName) + && _equal(a._requireTypeIdForSubtypes, b._requireTypeIdForSubtypes) + ; + } + + private static <T> boolean _equal(T value1, T value2) + { + if (value1 == null) { + return (value2 == null); + } + if (value2 == null) { + return false; + } + return value1.equals(value2); + } + } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jackson-annotations-jackson-annotations-2.15.2/src/test/java/com/fasterxml/jackson/annotation/JsonTypeInfoTest.java new/jackson-annotations-jackson-annotations-2.16.1/src/test/java/com/fasterxml/jackson/annotation/JsonTypeInfoTest.java --- old/jackson-annotations-jackson-annotations-2.15.2/src/test/java/com/fasterxml/jackson/annotation/JsonTypeInfoTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/jackson-annotations-jackson-annotations-2.16.1/src/test/java/com/fasterxml/jackson/annotation/JsonTypeInfoTest.java 2023-12-24 05:01:46.000000000 +0100 @@ -0,0 +1,105 @@ +package com.fasterxml.jackson.annotation; + +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; + +public class JsonTypeInfoTest extends TestBase +{ + @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, visible=true, + defaultImpl = JsonTypeInfo.class, requireTypeIdForSubtypes = OptBoolean.TRUE) + private final static class Anno1 { } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.EXTERNAL_PROPERTY, + property = "ext", + defaultImpl = Void.class, requireTypeIdForSubtypes = OptBoolean.FALSE) + private final static class Anno2 { } + + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.EXTERNAL_PROPERTY, + property = "ext", + defaultImpl = Void.class) + private final static class Anno3 { } + + public void testEmpty() { + // 07-Mar-2017, tatu: Important to distinguish "none" from 'empty' value... + assertNull(JsonTypeInfo.Value.from(null)); + } + + public void testFromAnnotation() throws Exception + { + JsonTypeInfo.Value v1 = JsonTypeInfo.Value.from(Anno1.class.getAnnotation(JsonTypeInfo.class)); + assertEquals(JsonTypeInfo.Id.CLASS, v1.getIdType()); + // default from annotation definition + assertEquals(JsonTypeInfo.As.PROPERTY, v1.getInclusionType()); + // default from annotation definition + assertEquals("@class", v1.getPropertyName()); + assertTrue(v1.getIdVisible()); + assertNull(v1.getDefaultImpl()); + assertTrue(v1.getRequireTypeIdForSubtypes()); + + JsonTypeInfo.Value v2 = JsonTypeInfo.Value.from(Anno2.class.getAnnotation(JsonTypeInfo.class)); + assertEquals(JsonTypeInfo.Id.NAME, v2.getIdType()); + assertEquals(JsonTypeInfo.As.EXTERNAL_PROPERTY, v2.getInclusionType()); + assertEquals("ext", v2.getPropertyName()); + assertFalse(v2.getIdVisible()); + assertEquals(Void.class, v2.getDefaultImpl()); + assertFalse(v2.getRequireTypeIdForSubtypes()); + + assertTrue(v1.equals(v1)); + assertTrue(v2.equals(v2)); + + assertFalse(v1.equals(v2)); + assertFalse(v2.equals(v1)); + + assertEquals("JsonTypeInfo.Value(idType=CLASS,includeAs=PROPERTY,propertyName=@class,defaultImpl=NULL,idVisible=true,requireTypeIdForSubtypes=true)", v1.toString()); + assertEquals("JsonTypeInfo.Value(idType=NAME,includeAs=EXTERNAL_PROPERTY,propertyName=ext,defaultImpl=java.lang.Void,idVisible=false,requireTypeIdForSubtypes=false)", v2.toString()); + } + + public void testMutators() throws Exception + { + JsonTypeInfo.Value v = JsonTypeInfo.Value.from(Anno1.class.getAnnotation(JsonTypeInfo.class)); + assertEquals(JsonTypeInfo.Id.CLASS, v.getIdType()); + + assertSame(v, v.withIdType(JsonTypeInfo.Id.CLASS)); + JsonTypeInfo.Value v2 = v.withIdType(JsonTypeInfo.Id.MINIMAL_CLASS); + assertEquals(JsonTypeInfo.Id.MINIMAL_CLASS, v2.getIdType()); + JsonTypeInfo.Value v3 = v.withIdType(JsonTypeInfo.Id.SIMPLE_NAME); + assertEquals(JsonTypeInfo.Id.SIMPLE_NAME, v3.getIdType()); + + assertEquals(JsonTypeInfo.As.PROPERTY, v.getInclusionType()); + assertSame(v, v.withInclusionType(JsonTypeInfo.As.PROPERTY)); + v2 = v.withInclusionType(JsonTypeInfo.As.EXTERNAL_PROPERTY); + assertEquals(JsonTypeInfo.As.EXTERNAL_PROPERTY, v2.getInclusionType()); + + assertSame(v, v.withDefaultImpl(null)); + v2 = v.withDefaultImpl(String.class); + assertEquals(String.class, v2.getDefaultImpl()); + + assertSame(v, v.withIdVisible(true)); + assertFalse(v.withIdVisible(false).getIdVisible()); + + assertEquals("foobar", v.withPropertyName("foobar").getPropertyName()); + } + + public void testWithRequireTypeIdForSubtypes() { + JsonTypeInfo.Value empty = JsonTypeInfo.Value.EMPTY; + assertNull(empty.getRequireTypeIdForSubtypes()); + + JsonTypeInfo.Value requireTypeIdTrue = empty.withRequireTypeIdForSubtypes(Boolean.TRUE); + assertEquals(Boolean.TRUE, requireTypeIdTrue.getRequireTypeIdForSubtypes()); + + JsonTypeInfo.Value requireTypeIdFalse = empty.withRequireTypeIdForSubtypes(Boolean.FALSE); + assertEquals(Boolean.FALSE, requireTypeIdFalse.getRequireTypeIdForSubtypes()); + + JsonTypeInfo.Value requireTypeIdDefault = empty.withRequireTypeIdForSubtypes(null); + assertNull(requireTypeIdDefault.getRequireTypeIdForSubtypes()); + } + + public void testDefaultValueForRequireTypeIdForSubtypes() { + // default value + JsonTypeInfo.Value v3 = JsonTypeInfo.Value.from(Anno3.class.getAnnotation(JsonTypeInfo.class)); + assertNull(v3.getRequireTypeIdForSubtypes()); + + // toString() + assertEquals("JsonTypeInfo.Value(idType=NAME,includeAs=EXTERNAL_PROPERTY,propertyName=ext," + + "defaultImpl=java.lang.Void,idVisible=false,requireTypeIdForSubtypes=null)", v3.toString()); + } +} ++++++ jackson-annotations-build.xml ++++++ --- /var/tmp/diff_new_pack.V1xVC5/_old 2024-03-11 15:41:44.231664679 +0100 +++ /var/tmp/diff_new_pack.V1xVC5/_new 2024-03-11 15:41:44.231664679 +0100 @@ -11,12 +11,13 @@ <property name="project.groupId" value="com.fasterxml.jackson.core"/> <property name="project.artifactId" value="jackson-annotations"/> <property name="project.name" value="Jackson-annotations"/> - <property name="project.version" value="2.15.2"/> + <property name="project.version" value="2.16.1"/> <property name="project.vendor" value="FasterXML"/> <property name="project.description" value="Core annotations used for value types, used by Jackson data binding package."/> <property name="bundle.version" value="${project.version}"/> - <property name="compiler.source" value="1.8"/> + <property name="compiler.release" value="8"/> + <property name="compiler.source" value="1.${compiler.release}"/> <property name="compiler.target" value="${compiler.source}"/> <property name="build.finalName" value="${project.artifactId}-${project.version}"/> @@ -58,6 +59,7 @@ debug="true" optimize="false" deprecation="true" + release="${compiler.release}" target="${compiler.target}" verbose="false" fork="false" @@ -84,6 +86,7 @@ debug="true" optimize="false" deprecation="true" + release="${compiler.release}" target="${compiler.target}" verbose="false" fork="false"