diff --git a/AUTHORS b/AUTHORS index 380ed790..4a6ef2fd 100755 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ Philipp Eichhorn Philippe Charles Pim van der Loos Rabea Gransberger +Rafael Alemañ Cabrera <2362816+ralemanc@users.noreply.github.com> Raul Wißfeld Reinier Zwitserloot Rob Stryker diff --git a/src/core/lombok/eclipse/handlers/HandleJacksonized.java b/src/core/lombok/eclipse/handlers/HandleJacksonized.java index 6463cfb8..360e499f 100644 --- a/src/core/lombok/eclipse/handlers/HandleJacksonized.java +++ b/src/core/lombok/eclipse/handlers/HandleJacksonized.java @@ -193,10 +193,11 @@ public class HandleJacksonized extends EclipseAnnotationHandler { // Add @JsonProperty to all fields. It will be automatically copied to the getter/setters later. for (EclipseNode eclipseNode : tdNode.down()) { if (eclipseNode.getKind() == Kind.FIELD) { - if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) || + if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) || hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_IGNORE2)) { - return; - } else if (eclipseNode.isTransient()) { + continue; + } + if (eclipseNode.isTransient()) { createJsonIgnoreForField(eclipseNode, annotationNode); } else { createJsonPropertyForField(eclipseNode, annotationNode); diff --git a/src/core/lombok/javac/handlers/HandleJacksonized.java b/src/core/lombok/javac/handlers/HandleJacksonized.java index bf945847..e5484d38 100644 --- a/src/core/lombok/javac/handlers/HandleJacksonized.java +++ b/src/core/lombok/javac/handlers/HandleJacksonized.java @@ -118,9 +118,9 @@ public class HandleJacksonized extends JavacAnnotationHandler { if (javacNode.getKind() == Kind.FIELD) { if (hasAnnotation(javacNode, JacksonAnnotationType.JSON_PROPERTY2) || hasAnnotation(javacNode, JacksonAnnotationType.JSON_IGNORE2)) { - - return; - } else if (javacNode.isTransient()) { + continue; + } + if (javacNode.isTransient()) { createJsonIgnoreForField(javacNode, annotationNode); } else { createJsonPropertyForField(javacNode, annotationNode); diff --git a/test/transform/resource/after-delombok/JacksonizedBuilderFluent.java b/test/transform/resource/after-delombok/JacksonizedBuilderFluent.java new file mode 100644 index 00000000..10c9fd92 --- /dev/null +++ b/test/transform/resource/after-delombok/JacksonizedBuilderFluent.java @@ -0,0 +1,82 @@ +import com.fasterxml.jackson.annotation.JsonProperty; + +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder.class) +@tools.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder.class) +public class JacksonizedBuilderFluent { + @com.fasterxml.jackson.annotation.JsonProperty("fieldName1") + private String fieldName1; + @JsonProperty("FieldName2") + private String fieldName2; + @com.fasterxml.jackson.annotation.JsonProperty("fieldName3") + private String fieldName3; + @java.lang.SuppressWarnings("all") + @lombok.Generated + JacksonizedBuilderFluent(final String fieldName1, final String fieldName2, final String fieldName3) { + this.fieldName1 = fieldName1; + this.fieldName2 = fieldName2; + this.fieldName3 = fieldName3; + } + @java.lang.SuppressWarnings("all") + @lombok.Generated + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "", buildMethodName = "build") + @tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "", buildMethodName = "build") + public static class JacksonizedBuilderFluentBuilder { + @java.lang.SuppressWarnings("all") + @lombok.Generated + private String fieldName1; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private String fieldName2; + @java.lang.SuppressWarnings("all") + @lombok.Generated + private String fieldName3; + @java.lang.SuppressWarnings("all") + @lombok.Generated + JacksonizedBuilderFluentBuilder() { + } + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName1(final String fieldName1) { + this.fieldName1 = fieldName1; + return this; + } + /** + * @return {@code this}. + */ + @JsonProperty("FieldName2") + @java.lang.SuppressWarnings("all") + @lombok.Generated + public JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName2(final String fieldName2) { + this.fieldName2 = fieldName2; + return this; + } + /** + * @return {@code this}. + */ + @java.lang.SuppressWarnings("all") + @lombok.Generated + public JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName3(final String fieldName3) { + this.fieldName3 = fieldName3; + return this; + } + @java.lang.SuppressWarnings("all") + @lombok.Generated + public JacksonizedBuilderFluent build() { + return new JacksonizedBuilderFluent(this.fieldName1, this.fieldName2, this.fieldName3); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + @lombok.Generated + public java.lang.String toString() { + return "JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder(fieldName1=" + this.fieldName1 + ", fieldName2=" + this.fieldName2 + ", fieldName3=" + this.fieldName3 + ")"; + } + } + @java.lang.SuppressWarnings("all") + @lombok.Generated + public static JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder builder() { + return new JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/JacksonizedAccessorsTransient.java b/test/transform/resource/after-ecj/JacksonizedAccessorsTransient.java index b9227f61..4b264221 100644 --- a/test/transform/resource/after-ecj/JacksonizedAccessorsTransient.java +++ b/test/transform/resource/after-ecj/JacksonizedAccessorsTransient.java @@ -5,7 +5,7 @@ public @lombok.extern.jackson.Jacksonized @lombok.experimental.Accessors(fluent public JacksonizedAccessorsTransient() { super(); } - public @java.lang.SuppressWarnings("all") @lombok.Generated int intValue() { + public @com.fasterxml.jackson.annotation.JsonIgnore @java.lang.SuppressWarnings("all") @lombok.Generated int intValue() { return this.intValue; } public @com.fasterxml.jackson.annotation.JsonIgnore @java.lang.SuppressWarnings("all") @lombok.Generated long longValue() { @@ -17,7 +17,7 @@ public @lombok.extern.jackson.Jacksonized @lombok.experimental.Accessors(fluent /** * @return {@code this}. */ - public @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedAccessorsTransient intValue(final int intValue) { + public @com.fasterxml.jackson.annotation.JsonIgnore @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedAccessorsTransient intValue(final int intValue) { this.intValue = intValue; return this; } diff --git a/test/transform/resource/after-ecj/JacksonizedBuilderFluent.java b/test/transform/resource/after-ecj/JacksonizedBuilderFluent.java new file mode 100644 index 00000000..49de313e --- /dev/null +++ b/test/transform/resource/after-ecj/JacksonizedBuilderFluent.java @@ -0,0 +1,50 @@ +import com.fasterxml.jackson.annotation.JsonProperty; +public @lombok.extern.jackson.Jacksonized @lombok.experimental.Accessors(fluent = true) @lombok.Builder @com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder.class) @tools.jackson.databind.annotation.JsonDeserialize(builder = JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder.class) class JacksonizedBuilderFluent { + public static @java.lang.SuppressWarnings("all") @lombok.Generated @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "",buildMethodName = "build") @tools.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "",buildMethodName = "build") class JacksonizedBuilderFluentBuilder { + private @java.lang.SuppressWarnings("all") @lombok.Generated String fieldName1; + private @java.lang.SuppressWarnings("all") @lombok.Generated String fieldName2; + private @java.lang.SuppressWarnings("all") @lombok.Generated String fieldName3; + @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluentBuilder() { + super(); + } + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName1(final String fieldName1) { + this.fieldName1 = fieldName1; + return this; + } + /** + * @return {@code this}. + */ + public @JsonProperty("FieldName2") @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName2(final String fieldName2) { + this.fieldName2 = fieldName2; + return this; + } + /** + * @return {@code this}. + */ + public @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder fieldName3(final String fieldName3) { + this.fieldName3 = fieldName3; + return this; + } + public @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent build() { + return new JacksonizedBuilderFluent(this.fieldName1, this.fieldName2, this.fieldName3); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() { + return (((((("JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder(fieldName1=" + this.fieldName1) + ", fieldName2=") + this.fieldName2) + ", fieldName3=") + this.fieldName3) + ")"); + } + } + private @com.fasterxml.jackson.annotation.JsonProperty("fieldName1") String fieldName1; + private @JsonProperty("FieldName2") String fieldName2; + private @com.fasterxml.jackson.annotation.JsonProperty("fieldName3") String fieldName3; + @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent(final String fieldName1, final String fieldName2, final String fieldName3) { + super(); + this.fieldName1 = fieldName1; + this.fieldName2 = fieldName2; + this.fieldName3 = fieldName3; + } + public static @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder builder() { + return new JacksonizedBuilderFluent.JacksonizedBuilderFluentBuilder(); + } +} diff --git a/test/transform/resource/before/JacksonizedBuilderFluent.java b/test/transform/resource/before/JacksonizedBuilderFluent.java new file mode 100644 index 00000000..2c37e40f --- /dev/null +++ b/test/transform/resource/before/JacksonizedBuilderFluent.java @@ -0,0 +1,13 @@ +//CONF: lombok.jacksonized.jacksonVersion += 2 +//CONF: lombok.jacksonized.jacksonVersion += 3 +import com.fasterxml.jackson.annotation.JsonProperty; + +@lombok.extern.jackson.Jacksonized +@lombok.experimental.Accessors(fluent=true) +@lombok.Builder +public class JacksonizedBuilderFluent { + private String fieldName1; + @JsonProperty("FieldName2") + private String fieldName2; + private String fieldName3; +}