Skip to content

Instantly share code, notes, and snippets.

@alexruzenhack
Last active November 27, 2018 14:28
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 alexruzenhack/03fac2587cd656cfb29f881364afae36 to your computer and use it in GitHub Desktop.
Save alexruzenhack/03fac2587cd656cfb29f881364afae36 to your computer and use it in GitHub Desktop.
📙 This #enum implements static functions in enum to get self values, and a list of parameters.
public enum Status {
P("Pending"),
A("Approved");
private String name;
Status(String name) {
this.name = name;
}
public String nameStatus() {
return name;
}
public static List<Status> listStatus() {
List<Status> listStatus = new ArrayList<Status>();
for (Status status : Status.values()) {
listStatus.add(status);
}
return listStatus;
}
public static List<String> listName() {
List<String> names = new ArrayList<String>();
for (Status status : Status.values()) {
names.add(status.name());
}
return names;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment