Skip to content

Instantly share code, notes, and snippets.

@sankars
Created April 11, 2014 15:31
Show Gist options
  • Select an option

  • Save sankars/10478115 to your computer and use it in GitHub Desktop.

Select an option

Save sankars/10478115 to your computer and use it in GitHub Desktop.
public enum Blah {
A("text1"),
B("text2"),
C("text3"),
D("text4");
private String text;
Blah(String text) {
this.text = text;
}
public String getText() {
return this.text;
}
public static Blah fromString(String text) {
if (text != null) {
for (Blah b : Blah.values()) {
if (text.equalsIgnoreCase(b.text)) {
return b;
}
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment