Skip to content

Instantly share code, notes, and snippets.

@asflierl
Last active April 26, 2018 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asflierl/84537bea60a9ed64db50653adc1a3580 to your computer and use it in GitHub Desktop.
Save asflierl/84537bea60a9ed64db50653adc1a3580 to your computer and use it in GitHub Desktop.
import java.util.Locale;
public enum EBoolA {
FALSE,
NULL,
TRUE;
public static final int fromBool(Boolean b) {
for (EBoolA mb : values()) {
StringBuilder sb = new StringBuilder();
String name = sb.append(b).toString();
if (mb.name().intern() == name.toUpperCase(Locale.US).intern()) {
return mb.ordinal() / 2;
}
}
throw new IllegalArgumentException("unknown boolean value: " + b);
}
}
@asflierl
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment