Skip to content

Instantly share code, notes, and snippets.

@dglozano
Created May 2, 2019 19:24
Show Gist options
  • Save dglozano/dd02efa15d070c5517c9e62e212ecd24 to your computer and use it in GitHub Desktop.
Save dglozano/dd02efa15d070c5517c9e62e212ecd24 to your computer and use it in GitHub Desktop.
public class Event<T> {
private boolean hasBeenHandled;
private T content;
public Event(T content) {
this.content = content;
this.hasBeenHandled = false;
}
public boolean hasBeenHandled() {
return hasBeenHandled;
}
public T handleContent() {
if(hasBeenHandled) {
return null;
} else {
hasBeenHandled = true;
return content;
}
}
public T peekContent() {
return content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment