@Test public void subscribe_whenCalledWithNullType_shouldThrow() { thrown.expect(NullPointerException.class); enabledBus.subscribe(null, e -> {}); }
@Override public synchronized <T> void subscribe( Class<T> type, Executor executor, EventHandler<? super T> handler) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(handler); Preconditions.checkNotNull(executor); if (!handlerMap.containsKey(type)) { handlerMap.put(type, new ConcurrentHashMap<>()); } @SuppressWarnings("unchecked") EventHandler<Object> casted = (EventHandler<Object>) handler; handlerMap.get(type).put(casted, executor); }
EventBus implements Subscriber, Publisher { @Override public synchronized <T> void subscribe( Class<T> type, Executor executor, EventHandler<? super T> handler) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(handler); Preconditions.checkNotNull(executor); if (!handlerMap.containsKey(type)) { handlerMap.put(type, new ConcurrentHashMap<>()); } @SuppressWarnings("unchecked") EventHandler<Object> casted = (EventHandler<Object>) handler; handlerMap.get(type).put(casted, executor); } }
EventBus implements Subscriber, Publisher { @Override public synchronized <T> void subscribe( Class<T> type, Executor executor, EventHandler<? super T> handler) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(handler); Preconditions.checkNotNull(executor); if (!handlerMap.containsKey(type)) { handlerMap.put(type, new ConcurrentHashMap<>()); } @SuppressWarnings("unchecked") EventHandler<Object> casted = (EventHandler<Object>) handler; handlerMap.get(type).put(casted, executor); } EventBus(Executor defaultExecutor); }
EventBus implements Subscriber, Publisher { @Override public synchronized <T> void subscribe( Class<T> type, Executor executor, EventHandler<? super T> handler) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(handler); Preconditions.checkNotNull(executor); if (!handlerMap.containsKey(type)) { handlerMap.put(type, new ConcurrentHashMap<>()); } @SuppressWarnings("unchecked") EventHandler<Object> casted = (EventHandler<Object>) handler; handlerMap.get(type).put(casted, executor); } EventBus(Executor defaultExecutor); @Override void publish(Event<?> event); @Override synchronized void subscribe(
      Class<T> type, Executor executor, EventHandler<? super T> handler); @Override void subscribe(Class<T> type, EventHandler<? super T> handler); @Override synchronized void unsubscribe(Class<T> type, EventHandler<? super T> handler); }
EventBus implements Subscriber, Publisher { @Override public synchronized <T> void subscribe( Class<T> type, Executor executor, EventHandler<? super T> handler) { Preconditions.checkNotNull(type); Preconditions.checkNotNull(handler); Preconditions.checkNotNull(executor); if (!handlerMap.containsKey(type)) { handlerMap.put(type, new ConcurrentHashMap<>()); } @SuppressWarnings("unchecked") EventHandler<Object> casted = (EventHandler<Object>) handler; handlerMap.get(type).put(casted, executor); } EventBus(Executor defaultExecutor); @Override void publish(Event<?> event); @Override synchronized void subscribe(
      Class<T> type, Executor executor, EventHandler<? super T> handler); @Override void subscribe(Class<T> type, EventHandler<? super T> handler); @Override synchronized void unsubscribe(Class<T> type, EventHandler<? super T> handler);  }