[QUESTION] Use enumerated annotations instead of enums
See original GitHub issueGiven how inefficient enum
s are on Android, would it be possible to leverage enumerated annotations instead of generating plain Java enum
s?
Issue Analytics
- State:
- Created 8 years ago
- Comments:9
Top Results From Across the Web
ENUMS VS ANNOTATIONS IN ANDROID. In ... - Anmol Sehgal
In android enums are not considered as a “Best-practise” to be used because of memory issues, as every enum type is an object...
Read more >Java Enums and Annotations Best Practices
1. Use enums instead of int constants. An enum type is a special data type that enables for a variable to be a...
Read more >How and when to use Enums and Annotations
In this part of the tutorial we are going to cover yet another two great features introduced into the language as part of...
Read more >How to supply Enum value to an annotation from a Constant in ...
Actually in order to use in a @RolesAllowed notation you would have to reference the value, NOT the enum. Example: @RolesAllowed({ Gender.Constants.MALE_VALUE }) ......
Read more >Enums & Annotations - The Java Interview Handbook
Use EnumSet instead of bit fields to efficiently store enum values of the same type. Methods in an EnumSet are implemented using arithmetic...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not working on a project that involves Thrift on Android atm so I won’t be able to try it in the near future. But thanks a lot for implementing it.
On Fri, 11 Nov 2016, 02:15 Ben Bader, notifications@github.com wrote:
Hmm, maybe I misunderstand. I’m thinking that quite a bit of that 1kb comes from the base class and associated code, which (thanks to object orientation) are shared across declarations. Certainly, methods like
Enum#values()
get deduplicated during dexing.As you say, it’s not exactly the case that using a few enums will ruin your app. I still hold the belief that the safety provided by enums outweighs their cost on-device. I certainly wouldn’t use such a feature as int-enums myself, but wouldn’t say no to having an option (non-default) to generate them.