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

Is there a way of making a specific collection unmodifiable when the makeCollectionsUnmodifiable is set to false #947

Open
Silfalion opened this issue Jul 13, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@Silfalion
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I have 2 unions classes, with a collection each, the collections are different from one another(not the same name). The second class collection need to be unmodifiable while on the other hand the first should be modifiable

Describe the solution you'd like
Ideallt, the first class should be modifiable while keeping the second one unmodifiable

Describe alternatives you've considered
I didn't see any, at least for now, though maybe a CollectionModifiable or CollectionUnmodifiable annotations would come in handy here?

Additional context

Thank you taking the time to read this issue

@rrousselGit
Copy link
Owner

You could manually override the getter to return an UnmodifiableListView

@rrousselGit rrousselGit added question Further information is requested and removed needs triage labels Jul 13, 2023
@Silfalion
Copy link
Contributor Author

True, thank you. Though would a PR be welcomed for this? Not necessary now, but I could give it a try if you see it's relevant enough

@rrousselGit
Copy link
Owner

Not for now. Freezed generally doesn't do field-specific thing. Like how we can't exclude one field from copyWith/==

@Silfalion
Copy link
Contributor Author

I understand. Well, thank you for your answer, appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants