Created
November 23, 2023 17:17
-
-
Save FyiurAmron/d903b6f4e6dca0d3132e6e8f7ade3c2a 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
interface Answer<T> {} | |
enum Answers implements Answer<Object> { | |
CALLS_REAL_METHODS(new Answer<>() {}), | |
RETURNS_SELF(new Answer<>() {}), | |
CUSTOM(null), | |
; | |
private Answer<Object> implementation; | |
Answers(Answer<Object> implementation) { | |
this.implementation = implementation; | |
} | |
void setCustomImplementation(Answer<Object> customImplementation) { | |
if (this != CUSTOM) { | |
throw new UnsupportedOperationException(); | |
} | |
implementation = customImplementation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment