2 ms·
You can use java.lang.ClassValue to store per-(enum-)class state generically. Meaning, instead of having to instrument each enum class, you could have MyE
by layer8 10mo ago
You can use java.lang.ClassValue to store per-(enum-)class state generically.
Meaning, instead of having to instrument each enum class, you could have
MyEnumHelper.of(AnyEnum.class)
.whateverFunctionalityYouWant()
where the of() implementation uses ClassValue to store the cached data.
- jimofl 10mo agoThis is a fantastic response! Tysvm for posting, and in detail.
- jimofl 10mo agoBTW, the solution I provided in my library already does exactly what you are describing in terms of not needing to instrument each enum class. The high value of your response, to me, is discovering I can replace my custom "Memoizer" mechanism with a platform-provided (and therefore superior to my custom code) solution with java.lang.ClassValue.
- deleted 10mo ago[deleted]