openrewrite / rewrite-jackson

OpenRewrite recipes for Jackson.
Apache License 2.0
1 stars 0 forks source link

Codehaus `@JsonSerialize` arguments about inclusion should move to `@JsonInclude` #4

Closed timtebeek closed 1 month ago

timtebeek commented 1 month ago

What problem are you trying to solve?

When upgrading from Codehaus to FasterXML, there's been a split in what gets configured where. A custom recipe is likely in order to correctly migrate to @JsonInclude and the arguments there.

Describe the situation before & after applying the recipe

@Test
void jsonSerializeToJsonInclude() {
    rewriteRun(
      //language=java
      java(
        """
          import org.codehaus.jackson.map.annotate.JsonSerialize;
          import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;

          @JsonSerialize(include = NON_NULL)
          class Test {
          }
          """,
        """
          import com.fasterxml.jackson.annotation.JsonInclude;
          import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

          @JsonInclude(value = NON_NULL)
          class Test {
          }
          """
      )
    );
}

Any additional context