Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of built_value enums over normal enums from the language

In the built_value lib I found the example how to make enums. So I'm a bit confused. Because I do not see right away what are the benefits of useing the built_value enums. Does some one know it? What do I overlook?

like image 241
swissonid Avatar asked Jun 27 '18 05:06

swissonid


2 Answers

Serialization is one thing; the other major one is that they are proper classes: you can add code to them, and they can implement interfaces.

In this way they're much like Java's enums.

like image 200
David Morgan Avatar answered Nov 13 '22 00:11

David Morgan


Mostly that they can easily be de/serialized from/to JSON.

Darts built-in enums are quite a bad fit where serialization is needed.

like image 24
Günter Zöchbauer Avatar answered Nov 12 '22 23:11

Günter Zöchbauer