line-bot-sdk-java icon indicating copy to clipboard operation
line-bot-sdk-java copied to clipboard

[Feature Request] Make all model class re-constructable / modifiable.

Open kazuki-ma opened this issue 5 years ago • 4 comments

Feature Request

Describe the solution you'd like

Changing specific field of model class (e.g. FlexMessage) is hard work for developer.

Adding lombok's @Builder(toBuilder = true) save us. (And optionally, @Wither is also useful)

Describe alternatives you've considered

    FlexMessage overWriteDirection(FlexMessage original) {
        Bubble originalBubble = (Bubble) original.getContents();

        FlexMessage modified = original
                .toBuilder()
                .contents(Bubble.builder()
                                .action(originalBubble.getAction())
                                .direction(FlexDirection.RTL)
                                .body(originalBubble.getBody())
                                .footer(originalBubble.getFooter())
                                .header(originalBubble.getHeader())
                                .hero(originalBubble.getHero())
                                .size(originalBubble.getSize())
                                .build())
                .build();
        
        return modified;

        // Result: Error because copying Bubble#style is missing... :sob:
    }

kazuki-ma avatar Oct 16 '19 12:10 kazuki-ma

https://github.com/line/line-bot-sdk-java/pull/254

kazuki-ma avatar Nov 27 '19 06:11 kazuki-ma

Can we close this issue?

tokuhirom avatar Mar 24 '20 06:03 tokuhirom

Thank you for remind me. Actually I think there are missing task in this ticket.

Especially, classes out of model/eventwill not changed in last PR.

(PR = Use builder style in model/event class to make adding field more easyly and safely. #254 )

kazuki-ma avatar Mar 24 '20 07:03 kazuki-ma

Let me leave this ticket open.

kazuki-ma avatar Mar 24 '20 07:03 kazuki-ma