-
-
Save gregorycfrank/7a88b5d00bc2c6646e208b0d72ffd86f to your computer and use it in GitHub Desktop.
This file contains 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 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