Skip to content

Instantly share code, notes, and snippets.

@mveitas
Created August 23, 2013 12:29
Show Gist options
  • Save mveitas/6318790 to your computer and use it in GitHub Desktop.
Save mveitas/6318790 to your computer and use it in GitHub Desktop.
public enum Foo {
Bar("Bar"),
Baz("Baz");
public final String value;
private Foo(final String value) {
this.value = value;
}
public static Foo parse(final String value) {
if (value.equals(Foo.Bar.value)) {
return Foo.Bar;
} else if (value.equals(Foo.Baz.value)) {
return Foo.Baz;
}
throw new IllegalArgumentException("Unsupported foo: " + value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment