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
Enums support #776
Comments
Hi @Egorand |
Hi @cmelchior and thanks for the response, |
True, but that would be very brittle with regard to modifying the enums afterwards. See here for a discussion on the topic: http://stackoverflow.com/questions/229856/ways-to-save-enums-in-database. It is possible to find a solution, but right now we want to prioritise other features. |
I would also like to see enum support. |
+1 |
+1! |
+1 |
1 similar comment
+1 |
is it possible to help you to speed up enum support? |
Any updates? |
Right now we are focusing on other bigger features (custom methods, null, async queries and migration API). However once we open up for custom methods it will be possible to work around this by doing the conversion yourself in the getter/setter. That said we still want to add support for it, but proper support will take a bit longer. |
+1 |
I don't know if it can help anybody, but here is what I use as a workaround : public enum CampaignStatus {
LIVE,
UPCOMING
}
@SerializedName("status")
private String statusRaw;
@Ignore
private transient CampaignStatus status;
public CampaignStatus getStatus() {
return CampaignStatus.valueOf(getStatusRaw().toUpperCase());
}
public void setStatus(CampaignStatus status) {
setStatusRaw(status.name());
} |
+1 |
5 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
? |
@Zhuinden the field |
+1 |
+1 |
I ran into this thread while trying to solve the same problem. Here was my approach to this in kotlin
basically I used a private string property taken as a string to construct a computed property with that enum correspondance. Not sure this is very "realm" friendly since I'm new to Android development but I thought this worked actually pretty well. |
+1 |
I think this is a subset of #1694 . |
Yes, it will most likely be implemented that way since the concept of a Java enum doesn't easily transfer to other platforms. |
I investigated ObjectBox today (don't worry; I'm sticking with Realm 😜 ), and came up with something like this for getting enums supported. Would something like that work here? |
+1 |
1 similar comment
+1 |
still no support? after so many years? |
how to store list of enum in realm android? |
|
How is this still not supported? |
2024 and still no real enum support? |
I was hoping enums are supported, as they're a better alternative to ints for enumerations.
The text was updated successfully, but these errors were encountered: