Skip to content

Instantly share code, notes, and snippets.

@FyiurAmron
Created November 23, 2023 17:17
Show Gist options
  • Save FyiurAmron/d903b6f4e6dca0d3132e6e8f7ade3c2a to your computer and use it in GitHub Desktop.
Save FyiurAmron/d903b6f4e6dca0d3132e6e8f7ade3c2a to your computer and use it in GitHub Desktop.
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