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 to add value fields to enumeration values #11

Closed
pedrorijo91 opened this Issue Dec 3, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@pedrorijo91

pedrorijo91 commented Dec 3, 2016

I think the problem has to do with extending a trait. If the enums extends abstract classes it should be easy to add this behaviour. On the other hand, it would forbid to create user hierarchies on the enumeration (not sure if interesting tough). Maybe another annotation could solve this problem, by letting the user choose between the available options?

example:

sealed abstract class Weekday( val name: String,
                               val abbreviation: String,
                               val isWorkDay: Boolean)

case object Monday extends Weekday("Monday", "Mo.", true)
case object Tuesday extends Weekday("Tuesday", "Tu.", true)
case object Wednesday extends Weekday("Wednesday", "We.", true)
case object Thursday extends Weekday("Thursday", "Th.", true)
case object Friday extends Weekday("Friday", "Fr.", true)
case object Saturday extends Weekday("Saturday", "Sa.", false)
case object Sunday extends Weekday("Sunday", "Su.", false)
@utaal

This comment has been minimized.

Show comment
Hide comment
@utaal

utaal Dec 7, 2016

Contributor

I'm not entirely sure of what you're looking for, here. Would you like to have the (String <-> Weekday, i.e. "Monday" <-> Monday) mappings where Weekday also has additional value fields? Depending on what you're looking for, this feels like it might be out of scope of the library, and probably better served by a custom implementation, but I do feel like having value fields (ignored by the mapping) may be worthwhile.

Contributor

utaal commented Dec 7, 2016

I'm not entirely sure of what you're looking for, here. Would you like to have the (String <-> Weekday, i.e. "Monday" <-> Monday) mappings where Weekday also has additional value fields? Depending on what you're looking for, this feels like it might be out of scope of the library, and probably better served by a custom implementation, but I do feel like having value fields (ignored by the mapping) may be worthwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment