Hey! I'm trying to write a custom decoder for a little argument parsing thing I'm working on and it's going all good, except that I can't seem to figure out a way to make enums case insensitive. The thing is that
decodeEnum
is given a string that it should try to match to a enum value index, but
SerialDescriptor#getElementIndex
doesn't seem to have any way to do a case insensitive lookup. Any ideas how I might achieve this?
Tmpod
09/01/2020, 9:03 PM
Never mind me, I went with using
SerialDescriptor#elementNames
with
firstOrNull { }
to get what I wanted.
Not sure if it's the best approach but it seems to work 🙂
If you got better ideas please let me know!