Skip to content

Instantly share code, notes, and snippets.

@gregorycfrank
Created September 15, 2022 18:10
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 gregorycfrank/7a88b5d00bc2c6646e208b0d72ffd86f to your computer and use it in GitHub Desktop.
Save gregorycfrank/7a88b5d00bc2c6646e208b0d72ffd86f to your computer and use it in GitHub Desktop.
public enum ParameterizedEnum<T> {
FIRST<Integer>(Integer::parseInt),
SECOND<Long>(Long::parsLong),
THIRD<BigInteger>(BigInteger::new),
;
private final Function<String, T> parser;
ParameterizedEnum(Function<String, T> parser) {
this.parser = parser;
}
T parse(String numberString) {
return parser.apply(numberString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment