Created
August 23, 2013 12:29
-
-
Save mveitas/6318790 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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