I wanted ease of use and comfort methods when using Java’s legacy Enum. Like resolving a value by its case-insensitive name or ordinal. Or easily, flexibly, and quickly, pretty-printing (a subset of) the Enum’s values, again by name and/or ordinal.
As old as Java’s Enum is, I think it’s absolutely fantastic. I just wanted to increase its fantastic-ness!
layer8•1mo 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
where the of() implementation uses ClassValue to store the cached data.
jimofl•1mo ago
This is a fantastic response!
Tysvm for posting, and in detail.
jimofl•1mo ago
BTW, 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.
jimofl•1mo ago
As old as Java’s Enum is, I think it’s absolutely fantastic. I just wanted to increase its fantastic-ness!
layer8•1mo ago
Meaning, instead of having to instrument each enum class, you could have
where the of() implementation uses ClassValue to store the cached data.jimofl•1mo ago
Tysvm for posting, and in detail.
jimofl•1mo ago
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.