@Test public void nullEventIsDisallowed() { CommandQueue<Void> queue = new CommandQueue<>(); try { queue.sendEvent(null); Assert.fail(); } catch(IllegalArgumentException e) { } }
public void sendEvent(@Nonnull final T event) { if(event == null) { throw new IllegalArgumentException("Null value is not allowed as an event"); } if(!canEmitEvents()) { if(limit == -1 || queuedEvents.size() < limit) { queuedEvents.add(event); } } else { sendCommandToReceiver(receiver, event); } }
CommandQueue { public void sendEvent(@Nonnull final T event) { if(event == null) { throw new IllegalArgumentException("Null value is not allowed as an event"); } if(!canEmitEvents()) { if(limit == -1 || queuedEvents.size() < limit) { queuedEvents.add(event); } } else { sendCommandToReceiver(receiver, event); } } }
CommandQueue { public void sendEvent(@Nonnull final T event) { if(event == null) { throw new IllegalArgumentException("Null value is not allowed as an event"); } if(!canEmitEvents()) { if(limit == -1 || queuedEvents.size() < limit) { queuedEvents.add(event); } } else { sendCommandToReceiver(receiver, event); } } CommandQueue(); }
CommandQueue { public void sendEvent(@Nonnull final T event) { if(event == null) { throw new IllegalArgumentException("Null value is not allowed as an event"); } if(!canEmitEvents()) { if(limit == -1 || queuedEvents.size() < limit) { queuedEvents.add(event); } } else { sendCommandToReceiver(receiver, event); } } CommandQueue(); boolean hasReceiver(); void setReceiver(@Nullable final Receiver<T> receiver); void setPaused(boolean paused); void detachReceiver(); void sendEvent(@Nonnull final T event); }
CommandQueue { public void sendEvent(@Nonnull final T event) { if(event == null) { throw new IllegalArgumentException("Null value is not allowed as an event"); } if(!canEmitEvents()) { if(limit == -1 || queuedEvents.size() < limit) { queuedEvents.add(event); } } else { sendCommandToReceiver(receiver, event); } } CommandQueue(); boolean hasReceiver(); void setReceiver(@Nullable final Receiver<T> receiver); void setPaused(boolean paused); void detachReceiver(); void sendEvent(@Nonnull final T event);  }