I have set of key-value pairs that I declare in the code, they are static values
lets say
"blah" to 10
"save" to 20
All of these are known at compile time (i.e declared static values),
Now if these were stored in HashMap
, map.get("somethingElse")
would not throw a compile time error, even though we know for sure at compile time that the map does not have that key.
My question is there a way/some trick to get this behavior in kotlin? Basically I want compiler to error out when trying to get a key that does not exist in a set of static key-value pairs.
I am not very knowledgeable about annotations, but is this achievable using annotation processing?