Skip to content

Support Lombok's fluent setters in reflection-free Jackson serialization #46647

@jdussouillez

Description

@jdussouillez

Description

I recently tried to use reflection-free Jackson serialization but I realized it doesn't work with Lombok's fluent setters (= not prefixed with set).

fluent: If true, the getter for pepper is just pepper(), and the setter is pepper(T newValue).

@Accessors(fluent = true) // This annotation enables fluent mode. Also, it's possible to enable it by adding `lombok.accessors.fluent=true` in `lombok.config` file.
public class User {

    @Setter
    @JsonProperty(required = true)
    private String id;
}

This generates my setter as id(String id) instead of setId(String id), so Quarkus's JacksonDeserializerFactory::isSetterMethod doesn't treat that as a setter method.

Possible workarounds:

  • Remove fluent mode
  • Keep fluent mode but add prefixed setters to classes

Implementation ideas

I guess the easiest solution would be to detect if the class contains fluent setters but I guess it's not that easy...

Lombok only adds lombok.Generated annotation on generated setters (it's added by default but it can be disabled).

Another implementation would be to have a configuration options, such as quarkus.lombok.fluent-accessors=true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/jacksonIssues related to Jackson (JSON library)kind/enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions