Skip to content

[1.4.1] POJO beans with chained/fluent setters fail to serialize #548

Description

@gamerover98

Context

Version: 1.4.1
JDK: 8

When defining configuration POJO beans mapped by ConfigMe's BeanPropertyType, using fluent setter methods (such as those generated by Lombok's @Accessors(chain = true) or custom return this; setters) breaks the JavaBean property introspection.

Reproducing Example

Consider a simplified configuration bean:

import lombok.*;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors(chain = true)
@NoArgsConstructor(access = AccessLevel.PUBLIC)
public class CustomConfigProperty {

    private boolean enabled = true;
    private String fileName = "";
    private int weight = 1;
    private int minHeight = 0;
    private int maxHeight = 255;
}

When registering and saving this bean via ConfigMe:

public static final Property<CustomConfigProperty[]> PROPERTIES =
    new PropertyBuilder.ArrayPropertyBuilder<>(
        new BeanPropertyType<>(new TypeInformation(CustomConfigProperty.class), DefaultMapper.getInstance()),
        CustomConfigProperty[]::new)
        .path("custom.properties")
        .defaultValue(new CustomConfigProperty[0])
        .build();

Expected Behavior

ConfigMe should map the bean's fields to YAML properties based on getters and setters.

Actual Behavior

ConfigMe does not recognize the fluent setters, resulting in empty YAML outputs or unpopulated instances when reading from configuration files.

Thank you ❤️

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions