diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3df40f91..95682190 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,7 @@ name: Build and Deploy Snapshot on: push: - branches: ['2.*'] + branches: ['3.*'] paths-ignore: - "README.md" - "release-notes/*" @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: ['8', '17', '21', '24'] + java_version: ['17', '21', '24'] env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" steps: @@ -41,7 +41,8 @@ jobs: id: projectVersion run: echo "version=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.5.1:evaluate -DforceStdout -Dexpression=project.version -q)" >> $GITHUB_OUTPUT - name: Deploy snapshot - if: ${{ github.event_name != 'pull_request' && matrix.java_version == '8' && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }} + # 14-Jul-2025, tatu: No longer published; 3.x branch not used + if: ${{ github.event_name != 'pull_request' && matrix.java_version == '17' && endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') && false }} env: CI_DEPLOY_USERNAME: ${{ secrets.CENTRAL_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CENTRAL_DEPLOY_PASSWORD }} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 5ceee7de..b9b1153a 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# https://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # 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.9.6/apache-maven-3.9.6-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.1/maven-wrapper-3.3.1.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/.travis.yml b/.travis.yml index 3e2b2f7d..9a6c2c67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: java +# Java 8 for Jackson 3: jdk: - openjdk8 - openjdk11 diff --git a/README.md b/README.md index 9aaf01a8..b660c862 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +# WARNING! Obsolete branch! + +As of 10-Jul-2025 this branch (`3.x`) is obsolete: as per [JSTEP-1](https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-1) Jackson 3.x will use 2.x versions of `jackson-annotations` -- so there will not be 3.x versions. + +------ + # Overview This project contains general purpose annotations for diff --git a/pom.xml b/pom.xml index 141cd6d5..a6dcf269 100644 --- a/pom.xml +++ b/pom.xml @@ -6,17 +6,21 @@ 4.0.0 + + + - com.fasterxml.jackson - - jackson-parent - 2.20-SNAPSHOT + tools.jackson + jackson-base + 3.0.0 com.fasterxml.jackson.core jackson-annotations Jackson-annotations - 2.20-SNAPSHOT + 3.0-NEVER-SNAPSHOT jar Core annotations used for value types, used by Jackson data binding package. @@ -24,44 +28,55 @@ The Apache Software License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt + http://www.apache.org/licenses/LICENSE-2.0.txt repo - https://github.com/FasterXML/jackson + http://github.com/FasterXML/jackson scm:git:git@github.com:FasterXML/jackson-annotations.git scm:git:git@github.com:FasterXML/jackson-annotations.git - https://github.com/FasterXML/jackson-annotations + http://github.com/FasterXML/jackson-annotations HEAD - - + 17 + 17 + com.fasterxml.jackson.annotation.*;version=${project.version} + + + 3.0.0-rc6-SNAPSHOT + - 2025-04-24T23:17:28Z + 2025-05-22T16:28:17Z - - org.junit.jupiter - junit-jupiter - ${version.junit5} - test + + org.junit.jupiter + junit-jupiter + test - + central-snapshots Sonatype Central Portal (snapshots) @@ -70,54 +85,16 @@ true - + - - - - - org.cyclonedx - cyclonedx-maven-plugin - - true - sbom-cyclonedx - - - - - - org.moditect - moditect-maven-plugin - - - add-module-infos - package - - add-module-info - - - true - - src/moditect/module-info.java - - - - - - org.sonatype.central central-publishing-maven-plugin - + org.codehaus.mojo build-helper-maven-plugin @@ -169,12 +146,12 @@ + org.gradlex gradle-module-metadata-maven-plugin - 1.0 @@ -182,11 +159,13 @@ - + + + org.cyclonedx + cyclonedx-maven-plugin + + - diff --git a/release-notes/VERSION b/release-notes/VERSION new file mode 100644 index 00000000..28110878 --- /dev/null +++ b/release-notes/VERSION @@ -0,0 +1,34 @@ +NOTE: OBSOLETE -- Jackson 3.x will use 2.x `jackson-annotations` + +------------------------------------------------------------------------ + +Project: jackson-annotations +Versions: 3.x (for earlier, see VERSION-2.x) + +Contains definitions of standard Jackson annotation definitions, as well +as minimal set of support types (value classes created from annotations, +mostly) + +------------------------------------------------------------------------ +=== Releases === +------------------------------------------------------------------------ + +3.0-rc5 (22-May-2025) +3.0-rc4 (10-May-2025) + +No changes since rc3. + +3.0-rc3 (13-Apr-2025) + +#286: jackson-annotations `3.0.0-rc2` not usable by gradle + (fixed by @pjfanning) + +3.0-rc2 (28-Mar-2025) + +No changes since rc1. + +3.0-rc1 (07-Mar-2025) + +#272: Require JDK17 for jackson-annotations 3.0 for proper `module-info.java` +#274: Change 3.0 to use `module-info.java` directly for build (instead of via Moditect) +- Change `JsonInclude.value`, `JsonInclude.content` to `USE_DEFAULTS` (from `ALWAYS`) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 7d026a7a..9d59cc36 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -107,7 +107,11 @@ No changes since 2.17 2.9.1 (07-Sep-2017) -#123: Add Automatic-Module-Name (`com.fasterxml.jackson.annotation`) for JDK9 interoperability +#123: Add Automatic-Module-Name (`com.fasterxml.jackson.annotation`) for + JDK9 interoperability +#124: Add new `PropertyAccessor` `SCALAR_CONSTRUCTOR`; `JsonAutoDetect.scalarConstructorVisibility +#129: Remove Target of `ElementType.CONSTRUCTOR` from `@JsonIgnoreProperties`, + `@JsonPropertyOrder` 2.9.0 (30-Jul-2017) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationValue.java b/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationValue.java index a6340893..e8e4127e 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationValue.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationValue.java @@ -9,8 +9,6 @@ * and possibly merged. The reason for such marker is to allow generic handling of * some of the annotations, as well as to allow easier injection of configuration * from sources other than annotations. - * - * @since 2.6 */ public interface JacksonAnnotationValue { diff --git a/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationsInside.java b/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationsInside.java index d30b84a2..1836c813 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationsInside.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JacksonAnnotationsInside.java @@ -13,8 +13,6 @@ * This can be useful in creating "combo-annotations" by having * a container annotation, which needs to be annotated with this * annotation as well as all annotations it 'contains'. - * - * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JacksonInject.java b/src/main/java/com/fasterxml/jackson/annotation/JacksonInject.java index d9d7fe60..43b3f219 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JacksonInject.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JacksonInject.java @@ -50,8 +50,6 @@ * @return {@link OptBoolean#FALSE} to throw an exception; {@link OptBoolean#TRUE} * to avoid throwing it; or {@link OptBoolean#DEFAULT} to use configure defaults * (which are same as {@link OptBoolean#FALSE} for Jackson 2.x) - * - * @since 2.20 */ public OptBoolean optional() default OptBoolean.DEFAULT; @@ -106,14 +104,6 @@ public static Value empty() { return EMPTY; } - @Deprecated //since 2.20 - public static Value construct(Object id, Boolean useInput) { - return construct(id, useInput, null); - } - - /** - * @since 2.20 - */ public static Value construct(Object id, Boolean useInput, Boolean optional) { if ("".equals(id)) { id = null; diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonAlias.java b/src/main/java/com/fasterxml/jackson/annotation/JsonAlias.java index 9dedc933..89501518 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonAlias.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonAlias.java @@ -54,7 +54,6 @@ *

* During deserialization, any of these JSON structures will be valid * and correctly mapped to the MEDIUM enum value: {"size": "m"}, {"size": "medium"}, or {"size": "M"}. - * @since 2.9 */ @Target({ElementType.ANNOTATION_TYPE, // for combo-annotations ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER// for properties (field, setter, ctor param) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonAnyGetter.java b/src/main/java/com/fasterxml/jackson/annotation/JsonAnyGetter.java index 4a7d4972..8fc34ed7 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonAnyGetter.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonAnyGetter.java @@ -34,8 +34,6 @@ * * @return True if annotation is enabled (normal case); false if it is to * be ignored (only useful for mix-in annotations to "mask" annotation - * - * @since 2.9 */ boolean enabled() default true; } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonAnySetter.java b/src/main/java/com/fasterxml/jackson/annotation/JsonAnySetter.java index 49472a3a..622d8f63 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonAnySetter.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonAnySetter.java @@ -12,7 +12,7 @@ * to set) or a field (of type {@link java.util.Map} or POJO) - * to be used as a "fallback" handler * for all otherwise unrecognized properties found from JSON content. - * It is similar to {@code javax.xml.bind.annotation.XmlAnyElement} + * It is similar to JAXB {@code javax.xml.bind.annotation.XmlAnyElement} annotation * in behavior; and can only be used to denote a single property * per type. *

@@ -39,8 +39,6 @@ * * @return True if annotation is enabled (normal case); false if it is to * be ignored (only useful for mix-in annotations to "mask" annotation) - * - * @since 2.9 */ boolean enabled() default true; } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonClassDescription.java b/src/main/java/com/fasterxml/jackson/annotation/JsonClassDescription.java index 9dfe197d..077b0742 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonClassDescription.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonClassDescription.java @@ -11,8 +11,6 @@ * type (class). * Currently used to populate the description field in generated JSON * Schemas. - * - * @since 2.7 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonCreator.java b/src/main/java/com/fasterxml/jackson/annotation/JsonCreator.java index 5ce9e044..9494ecd4 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonCreator.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonCreator.java @@ -58,15 +58,11 @@ * heuristics for choosing mode to use. * * @return Mode to use. - * - * @since 2.5 */ public Mode mode() default Mode.DEFAULT; /** * Enumeration of possible {@link #mode} values available. - * - * @since 2.5 */ public enum Mode { /** diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java b/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java index 9eb96bfd..a1cfe6cc 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonFormat.java @@ -47,8 +47,6 @@ * will not work as per-property annotation. * * - * - * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE}) @@ -116,8 +114,6 @@ * Note that underlying default setting depends on datatype (or more precisely * deserializer for it): for most date/time types, default is for leniency * to be enabled. - * - * @since 2.9 */ public OptBoolean lenient() default OptBoolean.DEFAULT; @@ -125,8 +121,6 @@ * Set of {@link JsonFormat.Feature}s to explicitly enable with respect * to handling of annotated property. This will have precedence over possible * global configuration. - * - * @since 2.6 */ public JsonFormat.Feature[] with() default { }; @@ -134,8 +128,6 @@ * Set of {@link JsonFormat.Feature}s to explicitly disable with respect * to handling of annotated property. This will have precedence over possible * global configuration. - * - * @since 2.6 */ public JsonFormat.Feature[] without() default { }; @@ -153,6 +145,7 @@ public enum Shape { // // // Concrete physical shapes, scalars + /** * Value that indicates that Binary type (native, if format supports it; * encoding using Base64 if only textual types supported) should be used. @@ -224,8 +217,6 @@ public enum Shape * for Java numbers. * Note that this is different from {@link Shape#ANY} in that this is actual * explicit choice that overrides possible default settings. - * - * @since 2.8 */ NATURAL, @@ -234,10 +225,9 @@ public enum Shape * handling as POJO, where applicable. Mostly makes difference at Java Object level * when distinguishing handling between {@link java.util.Map} and POJO types. * - * @since 2.20 + * @since 3.0 */ POJO, - ; public boolean isNumeric() { @@ -269,8 +259,6 @@ public static boolean isStructured(Shape shapeOrNull) { * takes the format setting into account. If not, please file an issue * for adding support via issue tracker for package that has handlers * (if you know which one; if not, just use `jackson-databind`). - * - * @since 2.6 */ public enum Feature { /** @@ -322,8 +310,6 @@ public enum Feature { * which allows case-sensitive matching of (some) property values, such * as {@code Enum}s. * Only affects deserialization, has no effect on serialization. - * - * @since 2.10 */ ACCEPT_CASE_INSENSITIVE_VALUES, @@ -363,8 +349,6 @@ public enum Feature { * {@link java.util.Date} and {@link java.util.Calendar}), this setting is only * applicable to Joda and Java 8 date/time values, * but not to java.util.Date or java.util.Calendar. - * - * @since 2.8 */ ADJUST_DATES_TO_CONTEXT_TIME_ZONE } @@ -372,8 +356,6 @@ public enum Feature { /** * Helper class that encapsulates information equivalent to {@link java.lang.Boolean} * valued {@link java.util.EnumMap}. - * - * @since 2.6 */ public static class Features { @@ -487,7 +469,7 @@ public boolean equals(Object o) { * annotation. */ public static class Value - implements JacksonAnnotationValue, // since 2.6 + implements JacksonAnnotationValue, java.io.Serializable { private static final long serialVersionUID = 1L; @@ -500,14 +482,8 @@ public static class Value private final String _timezoneStr; - /** - * @since 2.9 - */ private final Boolean _lenient; - /** - * @since 2.6 - */ private final Features _features; // lazily constructed when created from annotations @@ -522,9 +498,6 @@ public Value(JsonFormat ann) { Features.construct(ann), ann.lenient().asBoolean()); } - /** - * @since 2.9 - */ public Value(String p, Shape sh, String localeStr, String tzStr, Features f, Boolean lenient) { @@ -536,9 +509,6 @@ public Value(String p, Shape sh, String localeStr, String tzStr, Features f, null, f, lenient); } - /** - * @since 2.9 - */ public Value(String p, Shape sh, Locale l, TimeZone tz, Features f, Boolean lenient) { @@ -551,9 +521,6 @@ public Value(String p, Shape sh, Locale l, TimeZone tz, Features f, _lenient = lenient; } - /** - * @since 2.9 - */ public Value(String p, Shape sh, Locale l, String tzStr, TimeZone tz, Features f, Boolean lenient) { @@ -581,8 +548,6 @@ public final static Value empty() { * or logically missing). * Note that one or both of value instances may be `null`, directly; * if both are `null`, result will also be `null`; otherwise never null. - * - * @since 2.8 */ public static Value merge(Value base, Value overrides) { @@ -590,9 +555,6 @@ public static Value merge(Value base, Value overrides) : base.withOverrides(overrides); } - /** - * @since 2.8 - */ public static Value mergeAll(Value... values) { Value result = null; @@ -604,16 +566,10 @@ public static Value mergeAll(Value... values) return result; } - /** - * @since 2.7 - */ public final static Value from(JsonFormat ann) { return (ann == null) ? EMPTY : new Value(ann); } - /** - * @since 2.7 - */ public final Value withOverrides(Value overrides) { if ((overrides == null) || (overrides == EMPTY) || (overrides == this)) { return this; @@ -657,39 +613,24 @@ public final Value withOverrides(Value overrides) { return new Value(p, sh, l, tzStr, tz, f, lenient); } - /** - * @since 2.6 - */ public static Value forPattern(String p) { return new Value(p, null, null, null, null, Features.empty(), null); } - /** - * @since 2.7 - */ public static Value forShape(Shape sh) { return new Value("", sh, null, null, null, Features.empty(), null); } - /** - * @since 2.9 - */ public static Value forLeniency(boolean lenient) { return new Value("", null, null, null, null, Features.empty(), Boolean.valueOf(lenient)); } - /** - * @since 2.1 - */ public Value withPattern(String p) { return new Value(p, _shape, _locale, _timezoneStr, _timezone, _features, _lenient); } - /** - * @since 2.1 - */ public Value withShape(Shape s) { if (s == _shape) { return this; @@ -698,25 +639,16 @@ public Value withShape(Shape s) { _features, _lenient); } - /** - * @since 2.1 - */ public Value withLocale(Locale l) { return new Value(_pattern, _shape, l, _timezoneStr, _timezone, _features, _lenient); } - /** - * @since 2.1 - */ public Value withTimeZone(TimeZone tz) { return new Value(_pattern, _shape, _locale, null, tz, _features, _lenient); } - /** - * @since 2.9 - */ public Value withLenient(Boolean lenient) { if (lenient == _lenient) { return this; @@ -725,9 +657,6 @@ public Value withLenient(Boolean lenient) { _features, lenient); } - /** - * @since 2.6 - */ public Value withFeature(JsonFormat.Feature f) { Features newFeats = _features.with(f); return (newFeats == _features) ? this : @@ -735,9 +664,6 @@ public Value withFeature(JsonFormat.Feature f) { newFeats, _lenient); } - /** - * @since 2.6 - */ public Value withoutFeature(JsonFormat.Feature f) { Features newFeats = _features.without(f); return (newFeats == _features) ? this : @@ -758,8 +684,6 @@ public Class valueFor() { * @return {@code Boolean.TRUE} if explicitly set to true; {@code Boolean.FALSE} * if explicit set to false; or {@code null} if not set either way (assuming * "default leniency" for the context) - * - * @since 2.9 */ public Boolean getLenient() { return _lenient; @@ -772,8 +696,6 @@ public Boolean getLenient() { * * that is, returns {@code true} if (and only if) leniency has been explicitly * set to {code true}; but not if it is undefined. - * - * @since 2.9 */ public boolean isLenient() { return Boolean.TRUE.equals(_lenient); @@ -783,8 +705,6 @@ public boolean isLenient() { * Alternate access (compared to {@link #getTimeZone()}) which is useful * when caller just wants time zone id to convert, but not as JDK * provided {@link TimeZone} - * - * @since 2.4 */ public String timeZoneAsString() { if (_timezone != null) { @@ -805,26 +725,14 @@ public TimeZone getTimeZone() { return tz; } - /** - * @since 2.4 - */ public boolean hasShape() { return _shape != Shape.ANY; } - /** - * @since 2.4 - */ public boolean hasPattern() { return (_pattern != null) && (_pattern.length() > 0); } - /** - * @since 2.4 - */ public boolean hasLocale() { return _locale != null; } - /** - * @since 2.4 - */ public boolean hasTimeZone() { return (_timezone != null) || (_timezoneStr != null && !_timezoneStr.isEmpty()); } @@ -833,8 +741,6 @@ public boolean hasTimeZone() { * Accessor for checking whether there is a setting for leniency. * NOTE: does NOT mean that `lenient` is `true` necessarily; just that * it has been set. - * - * @since 2.9 */ public boolean hasLenient() { return _lenient != null; @@ -846,8 +752,6 @@ public boolean hasLenient() { * {@link Boolean#FALSE}, indicating 'yes/no/dunno' choices, where `null` ("dunno") * indicates that the default handling should be used based on global defaults, * and there is no format override. - * - * @since 2.6 */ public Boolean getFeature(JsonFormat.Feature f) { return _features.get(f); @@ -855,8 +759,6 @@ public Boolean getFeature(JsonFormat.Feature f) { /** * Accessor for getting full set of features enabled/disabled. - * - * @since 2.8 */ public Features getFeatures() { return _features; diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityInfo.java index 1bbb5cfa..9b45ed55 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityInfo.java @@ -26,8 +26,6 @@ * Finally, note that generator type of {@link ObjectIdGenerators.None} * indicates that no Object Id should be included or used: it is included * to allow suppressing Object Ids using mix-in annotations. - * - * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @@ -63,8 +61,6 @@ * Resolver to use for producing POJO from Object Identifier. *

* Default value is {@link SimpleObjectIdResolver} - * - * @since 2.4 */ public Class resolver() default SimpleObjectIdResolver.class; diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityReference.java b/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityReference.java index 00d2d8ff..5735515e 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityReference.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonIdentityReference.java @@ -11,8 +11,6 @@ * The main use case is that of enforcing use of Object Id even for the first * time an Object is referenced, instead of first instance being serialized * as full POJO. - * - * @since 2.1 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @@ -28,8 +26,6 @@ * Note that if value of 'true' is used, deserialization may require * additional contextual information, and possibly using a custom * id resolver -- the default handling may not be sufficient. - * - * @since 2.1 */ public boolean alwaysAsId() default false; } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonIgnoreProperties.java b/src/main/java/com/fasterxml/jackson/annotation/JsonIgnoreProperties.java index ab219c39..25707549 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonIgnoreProperties.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonIgnoreProperties.java @@ -27,7 +27,7 @@ * per-property annotation. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, - ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) + ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIgnoreProperties @@ -67,8 +67,6 @@ * * @return True if getters should be allowed (i.e. NOT ignored); false if getters * are to be ignored - * - * @since 2.6 */ public boolean allowGetters() default false; @@ -87,22 +85,19 @@ * * @return True if setters should be allowed (i.e. NOT ignored); false if setters * are to be ignored - * @since 2.6 */ public boolean allowSetters() default false; /* - /********************************************************** + /********************************************************************** /* Value class used to enclose information, allow for /* merging of layered configuration settings. - /********************************************************** + /********************************************************************** */ /** * Helper class used to contain information from a single {@link JsonIgnoreProperties} * annotation, as well as to provide possible overrides from non-annotation sources. - * - * @since 2.8 */ public static class Value implements JacksonAnnotationValue, @@ -146,7 +141,7 @@ protected Value(Set ignored, boolean ignoreUnknown, public static Value from(JsonIgnoreProperties src) { if (src == null) { - return EMPTY; // since 2.9 + return EMPTY; } return construct(_asSet(src.value()), src.ignoreUnknown(), src.allowGetters(), src.allowSetters(), @@ -207,9 +202,6 @@ public static Value merge(Value base, Value overrides) : base.withOverrides(overrides); } - /** - * @since 2.8 - */ public static Value mergeAll(Value... values) { Value result = null; @@ -300,6 +292,7 @@ public Value withAllowSetters() { return _allowSetters ? this : construct(_ignored, _ignoreUnknown, _allowGetters, true, _merge); } + public Value withoutAllowSetters() { return !_allowSetters ? this : construct(_ignored, _ignoreUnknown, _allowGetters, false, _merge); diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonInclude.java b/src/main/java/com/fasterxml/jackson/annotation/JsonInclude.java index 83bd9508..ad2f1d81 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonInclude.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonInclude.java @@ -39,11 +39,13 @@ *

* In addition to `Map`s, `content` concept is also supported for referential * types (like {@link java.util.concurrent.atomic.AtomicReference}). - * Note that `content` is NOT currently (as of Jackson 2.9) supported for - * arrays or {@link java.util.Collection}s, but supported may be added in - * future versions. - * - * @since 2.0 + *

+ * As of Jackson 3.1.0, {@link #content()} also supports {@link java.util.Collection}'s
+ * when {@code tools.jackson.databind.SerializationFeature#APPLY_JSON_INCLUDE_FOR_COLLECTIONS}
+ * feature is enabled --disabled by default for backward-compatibility. (see [databind#5369] for more detail)
+ *
+ * Note that `content` is NOT currently (as of Jackson 3.1.0) supported for
+ * arrays, but supported may be added in future versions.
  */
 @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD,
     ElementType.TYPE, ElementType.PARAMETER})
@@ -57,7 +59,7 @@
      *
      * @return Inclusion rule for value itself
      */
-    public Include value() default Include.ALWAYS;
+    public Include value() default Include.USE_DEFAULTS;
 
     /**
      * Inclusion rule to use for entries ("content") of annotated
@@ -66,10 +68,8 @@
      * defaults to {@link Include#ALWAYS}.
      *
      * @return Inclusion rule for content (elements, values of structured types)
-     *
-     * @since 2.5
      */
-    public Include content() default Include.ALWAYS;
+    public Include content() default Include.USE_DEFAULTS;
 
     /**
      * Specifies type of "Filter Object" to use in case
@@ -82,8 +82,6 @@
      * Filter's {@code equals(value)} method: if it returns {@code true}
      * value is NOT included (it is "filtered out"); if {@code false} value
      * IS included ("not filtered out").
-     *
-     * @since 2.9
      */
     public Class valueFilter() default Void.class;
 
@@ -98,8 +96,6 @@
      * Filter's {@code equals(value)} method: if it returns {@code true}
      * content value is NOT included (it is "filtered out"); if {@code false} content value
      * IS included ("not filtered out").
-     *
-     * @since 2.9
      */
     public Class contentFilter() default Void.class;
 
@@ -138,8 +134,6 @@ public enum Include
          *     that would not deference to a non-null value.
          * 
          * This option is mostly used to work with "Optional"s (Java 8, Guava).
-         *
-         * @since 2.6
          */
         NON_ABSENT,
 
@@ -222,12 +216,8 @@ public enum Include
          * to serialize; if it returns {@code true} value is excluded
          * (that is, filtered out); if {@code false} value is included.
          *

- * NOTE: the filter will be called for each non-{@code null} value, - * but handling of {@code null} value differs: up to Jackson 2.13, call - * was only made once, but with 2.14 and later filter will be called - * once for each {@code null} value too. - * - * @since 2.9 + * NOTE: the filter will be called for every value, including {@code null} + * values. */ CUSTOM, @@ -237,8 +227,6 @@ public enum Include * for a property this would use defaults for the class that contains * property, if any defined; and if none defined for that, then * global serialization inclusion details. - * - * @since 2.6 */ USE_DEFAULTS ; @@ -253,11 +241,9 @@ public enum Include /** * Helper class used to contain information from a single {@link JsonInclude} * annotation. - * - * @since 2.6 */ public static class Value - implements JacksonAnnotationValue, // since 2.6 + implements JacksonAnnotationValue, java.io.Serializable { private static final long serialVersionUID = 1L; @@ -268,14 +254,8 @@ public static class Value protected final Include _valueInclusion; protected final Include _contentInclusion; - /** - * @since 2.9 - */ protected final Class _valueFilter; - /** - * @since 2.9 - */ protected final Class _contentFilter; public Value(JsonInclude src) { @@ -303,8 +283,6 @@ public static Value empty() { * or logically missing). * Note that one or both of value instances may be `null`, directly; * if both are `null`, result will also be `null`; otherwise never null. - * - * @since 2.8 */ public static Value merge(Value base, Value overrides) { @@ -312,9 +290,6 @@ public static Value merge(Value base, Value overrides) : base.withOverrides(overrides); } - /** - * @since 2.8 - */ public static Value mergeAll(Value... values) { Value result = null; @@ -383,8 +358,6 @@ public static Value construct(Include valueIncl, Include contentIncl) { /** * Factory method to use for constructing an instance for components - * - * @since 2.9 */ public static Value construct(Include valueIncl, Include contentIncl, Class valueFilter, Class contentFilter) @@ -444,8 +417,6 @@ public Value withValueInclusion(Include incl) { *

  • Set value as ALWAYS (if filter null) *
  • * - * - * @since 2.9 */ public Value withValueFilter(Class filter) { Include incl; @@ -467,8 +438,6 @@ public Value withValueFilter(Class filter) { *
  • Set content as ALWAYS (if filter null) *
  • * - * - * @since 2.9 */ public Value withContentFilter(Class filter) { Include incl; diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonMerge.java b/src/main/java/com/fasterxml/jackson/annotation/JsonMerge.java index de4720a8..0ae0f2e7 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonMerge.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonMerge.java @@ -50,8 +50,6 @@ * and Object have "updating reader" operations. *

    * Default value is {@link OptBoolean#TRUE}, that is, merging is enabled. - * - * @since 2.9 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java b/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java index 10ef73eb..61221d3b 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java @@ -30,7 +30,7 @@ * since it would associate same annotation for all fields, leading to name * collision. *

    - * Starting with Jackson 2.6 this annotation may also be + * This annotation may also be * used to change serialization of {@code Enum} like so: *

     public enum MyEnum {
    @@ -43,9 +43,8 @@ public enum MyEnum {
      * NOTE: for {@code Enum}s, empty String is a valid value (and
      * missing {@code value} is taken as empty String), unlike for regular
      * properties, and does NOT mean "use default Enum name".
    - * (handling fixed in Jackson 2.19)
      *

    - * Starting with Jackson 2.12 it is also possible to specify {@code namespace} + * It is also possible to specify {@code namespace} * of property: this property is only used by certain format backends (most * notably XML). */ @@ -57,8 +56,6 @@ public enum MyEnum { /** * Special value that indicates that handlers should use the default * name (derived from method or field name) for property. - * - * @since 2.1 */ public final static String USE_DEFAULT_NAME = ""; @@ -66,8 +63,6 @@ public enum MyEnum { * Marker value used to indicate that no index has been specified. * Used as the default value as annotations do not allow "missing" * values. - * - * @since 2.4 */ public final static int INDEX_UNKNOWN = -1; @@ -86,18 +81,14 @@ public enum MyEnum { * Optional namespace to use with data formats that support such * concept (specifically XML); if so, used with {@link #value} to * construct fully-qualified name. - * - * @since 2.12 */ String namespace() default ""; /** - * Property similar to {@link #isRequired}, but one that only - * allows two values ({@code true} and {@code false}), defaulting - * to {@code false}. It also has lower precedence than {@link #isRequired} - * in cases where both are specified. - * - * @since 2.0 + * Property similar to {@link #isRequired} but one that has lower precedence + * and where only value of {@code true} has effect (if and only if + * {@link #isRequired} has value of {@code OptBoolean.DEFAULT}): + * specifying of value {@code false} basically means "use default settings". */ boolean required() default false; @@ -115,7 +106,7 @@ public enum MyEnum { * level settings (some modules may specify default "required-ness" for certain * kinds of properties). *

    - * Note that as of 2.19, possible validation is only done for Creator + * Note that as of 3.0, possible validation is only done for Creator * Properties, to ensure existence of property value in JSON: * for other properties (ones injected using a setter or mutable * field), no validation is performed. Support for those cases @@ -132,11 +123,9 @@ public enum MyEnum { * validation of {@code required} properties occurs before the application of * secondary sources. *

    - * NOTE: as of Jackson 2.19, the older property, {@link #required()}, + * NOTE: the older property, {@link #required()}, * may still be used, but will have lower precedence than this annotation -- * basically it is only considered if this property has value {@code OptBoolean.DEFAULT}. - * - * @since 2.19 */ OptBoolean isRequired() default OptBoolean.DEFAULT; @@ -145,8 +134,6 @@ public enum MyEnum { * to other properties specified for the Object). This index * is typically used by binary formats, but may also be useful * for schema languages and other tools. - * - * @since 2.4 */ int index() default INDEX_UNKNOWN; @@ -159,10 +146,7 @@ public enum MyEnum { * value through bean property introspection. *

    * It is possible that in future this annotation could be used for value - * defaulting, and especially for default values of Creator properties, - * since they support {@link #required()} in 2.6 and above. - * - * @since 2.5 + * defaulting. */ String defaultValue() default ""; @@ -175,8 +159,6 @@ public enum MyEnum { *

    * Default value os {@link Access#AUTO} which means that access is determined * solely based on visibility and other annotations. - * - * @since 2.6 */ Access access() default Access.AUTO; @@ -192,8 +174,6 @@ public enum MyEnum { * has precedence over this property. * This annotation property is, however, preferred over use of "split" * {@link JsonIgnore}/JsonProperty combination. - * - * @since 2.6 */ public enum Access { diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyDescription.java b/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyDescription.java index 5ed78a72..ba5c7997 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyDescription.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyDescription.java @@ -7,16 +7,12 @@ import java.lang.annotation.Target; /** - * Annotation used to define a human-readable description for a logical - * property. - * Currently used to populate the description field in generated JSON - * Schemas. - * - * @since 2.3 + * Annotation used to define a human-readable description for a logical property. + * Currently used to populate the description field in generated JSON Schemas. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) -@Documented // since 2.6 +@Documented @JacksonAnnotation public @interface JsonPropertyDescription { diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyOrder.java b/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyOrder.java index e32e238b..b5289d69 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyOrder.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonPropertyOrder.java @@ -26,11 +26,11 @@ * handling there is no effect, but for other supported data types (or structural * conventions) there may be. *

    - * NOTE: annotation is allowed for properties, starting with 2.4, mostly to support + * NOTE: annotation is allowed for properties mostly to support * alphabetic ordering of {@link java.util.Map} entries. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, - ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) + ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonPropertyOrder diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonRootName.java b/src/main/java/com/fasterxml/jackson/annotation/JsonRootName.java index 103d0bee..45e5ba08 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonRootName.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonRootName.java @@ -6,7 +6,7 @@ import java.lang.annotation.Target; /** - * Annotation similar to {@code javax.xml.bind.annotation.XmlRootElement}, + * Annotation similar to JAXB {@code javax.xml.bind.annotation.XmlRootElement}, * used to indicate name to use for root-level wrapping, if wrapping is * enabled. Annotation itself does not indicate that wrapping should * be used; but if it is, the name used for serialization should be the @@ -28,8 +28,6 @@ * Optional namespace to use with data formats that support such * concept (specifically XML); if so, used with {@link #value} to * construct fully-qualified name. - * - * @since 2.4 */ public String namespace() default ""; @@ -41,7 +39,6 @@ * Note that value of false is taken to mean "use defaults", * and will not block use of wrapper if use is indicated by global features. * - * @since 2.4 public boolean alwaysWrap() default false; */ } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonSetter.java b/src/main/java/com/fasterxml/jackson/annotation/JsonSetter.java index a0fb5bd5..b93ae0e0 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonSetter.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonSetter.java @@ -56,8 +56,6 @@ /** * Helper class used to contain information from a single {@link JsonSetter} * annotation, as well as to provide possible overrides from non-annotation sources. - * - * @since 2.9 */ public static class Value implements JacksonAnnotationValue, diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonSubTypes.java b/src/main/java/com/fasterxml/jackson/annotation/JsonSubTypes.java index 289c80a2..3f636b62 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonSubTypes.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonSubTypes.java @@ -32,8 +32,6 @@ * When set to true, logical type name and names are going to be checked * for repeated values. Repeated values are considered a definition violation * during that check. - * - * @since 2.14 */ public boolean failOnRepeatedNames() default false; @@ -59,8 +57,6 @@ /** * (optional) Logical type names used as the type identifier for the class: used if * more than one type name should be associated with the same type. - * - * @since 2.12 */ public String[] names() default {}; } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java index f69cbfbc..aa128694 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeId.java @@ -25,8 +25,6 @@ * {@link JsonTypeInfo.As#PROPERTY}), but is more commonly embedded * in a different place, as per inclusion rules (see {@link JsonTypeInfo} * for details). - * - * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java index de00f92f..f2e42120 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java @@ -1,9 +1,7 @@ package com.fasterxml.jackson.annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; +import java.util.Objects; /** * Annotation used for configuring details of if and how type information is @@ -236,8 +234,6 @@ public enum As { * whereas with {@link JsonTypeId}, output of regular property is suppressed. * 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 but databind only since 2.5. */ EXISTING_PROPERTY ; @@ -250,10 +246,9 @@ public enum As { */ /** - * Specifies kind of type metadata to use when serializing - * type information for instances of annotated type - * and its subtypes; as well as what is expected during - * deserialization. + * Specifies kind of type metadata to use when serializing type information + * for instances of annotated type and its subtypes; as well as what is expected + * during deserialization. */ public Id use(); @@ -299,15 +294,11 @@ public enum As { *

      *
    • {@link java.lang.Void} means that objects with unmappable (or missing) * type are to be mapped to null references. - * For backwards compatibility (2.5 and below), value of - * com.fasterxml.jackson.databind.annotation.NoClass is also allowed - * for such usage. *
    • *
    • Placeholder value of {@link JsonTypeInfo} (that is, this annotation type * itself} means "there is no default implementation" (in which - * case an error results from unmappable type). - * For backwards compatibility with earlier versions (2.5 and below), - * value of {@link JsonTypeInfo.None} may also be used. + * case an error results from unmappable type). Actually works for ALL + * annotation types (since they can not be instantiated) *
    • *
    */ @@ -322,28 +313,9 @@ public enum As { * Default value is false, meaning that Jackson handles and removes * the type identifier from JSON content that is passed to * JsonDeserializer. - * - * @since 2.0 */ public boolean visible() default false; - /* - /********************************************************** - /* Helper classes - /********************************************************** - */ - - /** - * This marker class that is only to be used with defaultImpl - * annotation property, to indicate that there is no default implementation - * specified. - * - * @deprecated Since 2.5, use any Annotation type (such as {@link JsonTypeInfo}), - * if such behavior is needed; this is rarely necessary. - */ - @Deprecated // since 2.5 - public abstract static class None {} - /** * Specifies whether the type ID should be strictly required during polymorphic * deserialization of its subtypes. @@ -357,8 +329,6 @@ public abstract static class None {} *

    * NOTE: This setting is specific to this type and will always override * the global configuration of {@code MapperFeature.REQUIRE_TYPE_ID_FOR_SUBTYPES}. - * - * @since 2.16 */ public OptBoolean requireTypeIdForSubtypes() default OptBoolean.DEFAULT; @@ -512,14 +482,8 @@ public String toString() { @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; + return Objects.hash(_idType, _inclusionType, _propertyName, _defaultImpl, _requireTypeIdForSubtypes) + + (_idVisible ? 11 : -17); } @Override @@ -536,20 +500,9 @@ private static boolean _equals(Value a, Value b) && (a._inclusionType == b._inclusionType) && (a._defaultImpl == b._defaultImpl) && (a._idVisible == b._idVisible) - && _equal(a._propertyName, b._propertyName) - && _equal(a._requireTypeIdForSubtypes, b._requireTypeIdForSubtypes) + && Objects.equals(a._propertyName, b._propertyName) + && Objects.equals(a._requireTypeIdForSubtypes, b._requireTypeIdForSubtypes) ; } - - private static boolean _equal(T value1, T value2) - { - if (value1 == null) { - return (value2 == null); - } - if (value2 == null) { - return false; - } - return value1.equals(value2); - } } } diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonValue.java b/src/main/java/com/fasterxml/jackson/annotation/JsonValue.java index f4273830..5498d184 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonValue.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonValue.java @@ -45,7 +45,7 @@ * @see JsonKey */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, - ElementType.FIELD // since 2.9 + ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonView.java b/src/main/java/com/fasterxml/jackson/annotation/JsonView.java index b0d4e159..57efa43b 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonView.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonView.java @@ -24,8 +24,8 @@ * type, unless overridden by per-property annotation. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, - ElementType.PARAMETER, // since 2.5 - ElementType.TYPE // since 2.9, to indicate "default view" for properties + ElementType.PARAMETER, + ElementType.TYPE // to indicate "default view" for properties }) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java index 7e79fb1b..5cc67553 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java +++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java @@ -44,8 +44,6 @@ public abstract class ObjectIdGenerator *

    * Default implementation returns false, so needs to be overridden * by Object-producing generators. - * - * @since 2.5 */ public boolean maySerializeAsObject() { return false; @@ -59,8 +57,6 @@ public boolean maySerializeAsObject() { * @param parser Parser that points to property name, in case generator needs * further verification (note: untyped, because JsonParser is defined * in `jackson-core`, and this package does not depend on it). - * - * @since 2.5 */ public boolean isValidReferencePropertyName(String name, Object parser) { return false; diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java index ceea44a2..bd3cece8 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java +++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java @@ -7,7 +7,7 @@ *

      *
    • {@link IntSequenceGenerator} *
    • {@link PropertyGenerator} - *
    • {@link StringIdGenerator} (since 2.7) + *
    • {@link StringIdGenerator} *
    • {@link UUIDGenerator} *
    *

    @@ -191,8 +191,6 @@ public boolean canUseFor(ObjectIdGenerator gen) { * keep track of id-to-Object mapping. Generation also works, although if * UUIDs are always used, {@link UUIDGenerator} is a better match as it * will also validate ids being used. - * - * @since 2.7 */ public final static class StringIdGenerator extends Base { diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdResolver.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdResolver.java index ad17f8a6..e52def2a 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdResolver.java +++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdResolver.java @@ -5,8 +5,6 @@ /** * Definition of API used for resolving actual Java object from * Object Identifiers (as annotated using {@link JsonIdentityInfo}). - * - * @since 2.4 */ public interface ObjectIdResolver { /** diff --git a/src/main/java/com/fasterxml/jackson/annotation/OptBoolean.java b/src/main/java/com/fasterxml/jackson/annotation/OptBoolean.java index e516e3f5..6e1d82da 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/OptBoolean.java +++ b/src/main/java/com/fasterxml/jackson/annotation/OptBoolean.java @@ -11,8 +11,6 @@ * can not be chosen since they are Java keyword and compiler won't allow * the choice. And since enum naming convention suggests all-upper-case, * that is what is done here. - * - * @since 2.6 */ public enum OptBoolean { diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 00000000..edb8e0bf --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,5 @@ +// Jackson 3.x module-info for jackson-annotations Main artifact +open module com.fasterxml.jackson.annotation +{ + exports com.fasterxml.jackson.annotation; +} diff --git a/src/moditect/module-info.java b/src/moditect/module-info.java deleted file mode 100644 index f64bf2e7..00000000 --- a/src/moditect/module-info.java +++ /dev/null @@ -1,4 +0,0 @@ -// Generated 08-Mar-2019 using Moditect maven plugin -open module com.fasterxml.jackson.annotation { - exports com.fasterxml.jackson.annotation; -} diff --git a/src/test/java/com/fasterxml/jackson/annotation/FormatShapeTest.java b/src/test/java/com/fasterxml/jackson/annotation/FormatShapeTest.java new file mode 100644 index 00000000..17c5905d --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/annotation/FormatShapeTest.java @@ -0,0 +1,84 @@ +package com.fasterxml.jackson.annotation; + +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.annotation.JsonFormat.Shape; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Tests to verify `shape`-related aspects of {@link JsonFormat.Value} handling. + */ +public class FormatShapeTest +{ + private final JsonFormat.Value EMPTY = JsonFormat.Value.empty(); + + @Test + public void testEquality() { + assertTrue(EMPTY.equals(EMPTY)); + assertTrue(new JsonFormat.Value().equals(new JsonFormat.Value())); + + JsonFormat.Value v1 = JsonFormat.Value.forShape(Shape.BOOLEAN); + JsonFormat.Value v2 = JsonFormat.Value.forShape(Shape.BOOLEAN); + JsonFormat.Value v3 = JsonFormat.Value.forShape(Shape.SCALAR); + + assertTrue(v1.equals(v2)); + assertTrue(v2.equals(v1)); + + assertFalse(v1.equals(v3)); + assertFalse(v3.equals(v1)); + assertFalse(v2.equals(v3)); + assertFalse(v3.equals(v2)); + + // not strictly guaranteed but... + assertFalse(v1.hashCode() == v3.hashCode()); + + assertEquals(v1, v3.withShape(Shape.BOOLEAN)); + } + + @Test + public void testShape() + { + assertFalse(Shape.STRING.isNumeric()); + assertFalse(Shape.isNumeric(Shape.STRING)); + assertFalse(Shape.STRING.isStructured()); + assertFalse(Shape.isStructured(Shape.STRING)); + + assertFalse(Shape.BOOLEAN.isNumeric()); + assertFalse(Shape.isNumeric(Shape.BOOLEAN)); + assertFalse(Shape.BOOLEAN.isStructured()); + assertFalse(Shape.isStructured(Shape.BOOLEAN)); + + assertTrue(Shape.NUMBER_INT.isNumeric()); + assertTrue(Shape.isNumeric(Shape.NUMBER_INT)); + assertTrue(Shape.NUMBER_FLOAT.isNumeric()); + assertTrue(Shape.isNumeric(Shape.NUMBER_FLOAT)); + assertTrue(Shape.NUMBER.isNumeric()); + assertTrue(Shape.isNumeric(Shape.NUMBER)); + + assertFalse(Shape.ARRAY.isNumeric()); + assertFalse(Shape.isNumeric(Shape.ARRAY)); + assertTrue(Shape.ARRAY.isStructured()); + assertTrue(Shape.isStructured(Shape.ARRAY)); + + assertFalse(Shape.OBJECT.isNumeric()); + assertFalse(Shape.isNumeric(Shape.OBJECT)); + assertTrue(Shape.OBJECT.isStructured()); + assertTrue(Shape.isStructured(Shape.OBJECT)); + + assertFalse(Shape.POJO.isNumeric()); + assertFalse(Shape.isNumeric(Shape.POJO)); + assertTrue(Shape.POJO.isStructured()); + assertTrue(Shape.isStructured(Shape.POJO)); + + assertFalse(Shape.ANY.isNumeric()); + assertFalse(Shape.isNumeric(Shape.ANY)); + assertFalse(Shape.ANY.isStructured()); + assertFalse(Shape.isStructured(Shape.ANY)); + + assertFalse(Shape.NATURAL.isNumeric()); + assertFalse(Shape.isNumeric(Shape.NATURAL)); + assertFalse(Shape.NATURAL.isStructured()); + assertFalse(Shape.isStructured(Shape.NATURAL)); + } +} diff --git a/src/test/java/com/fasterxml/jackson/annotation/FormatTest.java b/src/test/java/com/fasterxml/jackson/annotation/FormatTest.java index 68cb4f07..3fa1fac0 100644 --- a/src/test/java/com/fasterxml/jackson/annotation/FormatTest.java +++ b/src/test/java/com/fasterxml/jackson/annotation/FormatTest.java @@ -35,26 +35,9 @@ public void testEmptyInstanceDefaults() { @Test public void testEquality() { - assertTrue(EMPTY.equals(EMPTY)); - assertTrue(new JsonFormat.Value().equals(new JsonFormat.Value())); - JsonFormat.Value v1 = JsonFormat.Value.forShape(Shape.BOOLEAN); - JsonFormat.Value v2 = JsonFormat.Value.forShape(Shape.BOOLEAN); - JsonFormat.Value v3 = JsonFormat.Value.forShape(Shape.SCALAR); - - assertTrue(v1.equals(v2)); - assertTrue(v2.equals(v1)); - - assertFalse(v1.equals(v3)); - assertFalse(v3.equals(v1)); - assertFalse(v2.equals(v3)); - assertFalse(v3.equals(v2)); - - // not strictly guaranteed but... - assertFalse(v1.hashCode() == v3.hashCode()); // then let's converge - assertEquals(v1, v3.withShape(Shape.BOOLEAN)); assertFalse(v1.equals(v1.withPattern("ZBC"))); assertFalse(v1.equals(v1.withFeature(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))); assertFalse(v1.equals(v1.withoutFeature(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))); @@ -230,7 +213,8 @@ public void testFeatures() { assertTrue(f1.equals(f1)); assertFalse(f1.equals(f2)); assertFalse(f1.equals(null)); - assertFalse(f1.equals("foo")); + Object str = "foo"; + assertFalse(f1.equals(str)); assertNull(f1.get(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); assertEquals(Boolean.TRUE, f2.get(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY));