Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow creating setter definitions in interfaces #1388

Open
FyiurAmron opened this issue Nov 13, 2023 · 1 comment
Open

allow creating setter definitions in interfaces #1388

FyiurAmron opened this issue Nov 13, 2023 · 1 comment

Comments

@FyiurAmron
Copy link

FyiurAmron commented Nov 13, 2023

Is your feature request related to a problem? Please describe.
For some cases, e.g. error-as-data scenarios, you need to use a root interface to provide a structure for the errors. However, having getter-only interfaces makes creating code for them very hard, since it forces immutability even when it's counter-productive (i.e. error message construction).

Describe the solution you'd like
FTL templates for interface extended with setter generation, and config option added to allow enabling that.

Describe alternatives you've considered
There really aren't any; because the implementations are also autogenerated, there is no easy way to inject the setter interface part. The only way to have this done is manually writing the setters and manually creating a composite interface to be used in place of the autogenerated one, plus custom customTypesMapping to handle it.

It's also possible to supply the templates through customTemplates, but that requires copy-pasting an implementation-specific code (templates) and maintaining them later on.

@FyiurAmron
Copy link
Author

FyiurAmron commented Nov 24, 2023

@kobylynskyi what's your take on this? Do you think this would be reasonable? I could really use this option, and I can provide a PR with a simple implementation for it if you say it's OK for you - I can start working on this immediately because we have code freezes in December in my company, so I'll have spare time in the coming weeks and I could really use this modification, even if it seems small (it's a lot of custom boilerplate have to manage in our codebase due to it ATM).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant