EventWrapper.java 552 B

12345678910111213141516171819202122232425262728
  1. package epson.common;
  2. public class EventWrapper<T> {
  3. private boolean handled = false;
  4. private T mContent;
  5. public EventWrapper(T t) {
  6. if (t != null) {
  7. mContent = t;
  8. return;
  9. }
  10. throw new IllegalArgumentException("null values in Event are not allowed.");
  11. }
  12. @Nullable
  13. public T getEventContent() {
  14. if (handled) {
  15. return null;
  16. }
  17. handled = true;
  18. return mContent;
  19. }
  20. public boolean hasBeenHandled() {
  21. return handled;
  22. }
  23. }