Keep track of a reasonable 'unused' enum value for closed enum languages.
Summary:
For use in closed-enum languages that need any unused value to represent 'Unrecognized'. The actual value doesn't matter, because it is not representative of that value, but rather that the real value can only be accessed via a function that returns the raw i32 value. For example:
```
enum MyOption {
Option1 = 1,
}
```
might be handle as follows:
```
switch (val.option()) {
case Option1:
...
case MyOption.Unspecified: // == 0, added by Thrift v1 automatically.
throw new IllegalArgumentException("option must be specified")
case MyOption.Unrecognized: // == ?, added by codegen.
throw new NotImplementedException("unrecognized option: " + val.optionAsInt()); // The real value.
}
```
The actual implementation is (over) engineered to give the smallest unused value equal to or greater than 113 (a byte-sized unlikely prime number).
Also made `find by value` O(lnN) instead of O(N).
Reviewed By: robertroeser
Differential Revision:
D40969276
fbshipit-source-id:
f2ca3c75496c462a0e52d21852db68fa12ae73b3