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

ENUM raw values #307

Open
ysaakpr opened this issue Aug 18, 2023 · 3 comments
Open

ENUM raw values #307

ysaakpr opened this issue Aug 18, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@ysaakpr
Copy link

ysaakpr commented Aug 18, 2023

Are there anyway to add the raw received value of ENUM types. Many time we have customers whoes mobiles apps running an older version. Though the newly introduced ENUM can break some existing codes, we have always seen that the enum usage while in action goes through switch or conditional cases and we fallback to a default case.

I wonder are there anyway to preserve the received ENUM values as a rawValue. this will help the app developers sometime to fallback to display the raw value as is instead of the "unknown"

Any thoughts on bringing this?

@github-actions
Copy link

👋 @ysaakpr
Thank you for raising an issue. I will investigate the issue and get back to you as soon as possible.
Please make sure you have provided enough context.

This library is created and maintained by me, @budde377. Please consider supporting my work and ensure our survival by donating here.

@budde377 budde377 added the enhancement New feature or request label Aug 18, 2023
@budde377
Copy link
Contributor

Interesting use-case, I don't think we can use enhanced enums to solve this because they require a const constructor. We could possibly save a enumValue$raw field on the parent class for every enumValue fields.

class DataObject {
  Enum$Value enumValue;
  String enumValue$raw;

  List<Enum$Value> enumValues;
  List<String> enumValues$raw;
}

Let me think about it.

@ysaakpr
Copy link
Author

ysaakpr commented Aug 18, 2023

yeah... its about preserving the incoming value, and letting the client allowing to read the raw value as a string, can be still making sure we have the enum with unknown state and can still access the raw value that caused the unknown state, usfull for debugging or client app not so breaking for every change.

The app can show the raw value and say a warning, possibility u are using a old version of the app.

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

No branches or pull requests

2 participants