/** * Adds the map of {@link Class} to {@link TimedEventHandler} to the * builder. * @param entries The event handler mapping. * @return A new builder instance with the specified handlers added. */ public Builder withEventHandlers( Map<Class<? extends TimedEvent>, TimedEventHandler<?>> entries) { for (final Entry<Class<? extends TimedEvent>, TimedEventHandler<?>> entry : entries .entrySet()) { checkHandlerType(entry.getClass()); } return create( getScenario(), ImmutableMap .<Class<? extends TimedEvent>, TimedEventHandler<?>>builder() .putAll(getEventHandlers()) .putAll(entries) .build(), getNumberOfTicks(), getStopModelBuilder(), isIgnoreRedundantHandlers()); }
/** * Adds the map of {@link Class} to {@link TimedEventHandler} to the * builder. * @param entries The event handler mapping. * @return A new builder instance with the specified handlers added. */ public Builder withEventHandlers( Map<Class<? extends TimedEvent>, TimedEventHandler<?>> entries) { for (final Entry<Class<? extends TimedEvent>, TimedEventHandler<?>> entry : entries .entrySet()) { checkHandlerType(entry.getClass()); } return create( getScenario(), ImmutableMap .<Class<? extends TimedEvent>, TimedEventHandler<?>>builder() .putAll(getEventHandlers()) .putAll(entries) .build(), getNumberOfTicks(), getStopModelBuilder(), isIgnoreRedundantHandlers()); }
/** * Add a {@link TimedEventHandler} to the controller that handles * {@link TimedEvent}s of the specified type. * @param type The type of event to handle. * @param handler The handler that handles the event. * @param <T> The type of event to handle. * @return A new {@link Builder} instance. * @throws IllegalArgumentException If an interface class is provided. */ @CheckReturnValue public <T extends TimedEvent> Builder withEventHandler(Class<T> type, TimedEventHandler<T> handler) { checkHandlerType(type); return create( getScenario(), ImmutableMap .<Class<? extends TimedEvent>, TimedEventHandler<?>>builder() .putAll(getEventHandlers()).put(type, handler).build(), getNumberOfTicks(), getStopModelBuilder(), isIgnoreRedundantHandlers()); }
/** * Add a {@link TimedEventHandler} to the controller that handles * {@link TimedEvent}s of the specified type. * @param type The type of event to handle. * @param handler The handler that handles the event. * @param <T> The type of event to handle. * @return A new {@link Builder} instance. * @throws IllegalArgumentException If an interface class is provided. */ @CheckReturnValue public <T extends TimedEvent> Builder withEventHandler(Class<T> type, TimedEventHandler<T> handler) { checkHandlerType(type); return create( getScenario(), ImmutableMap .<Class<? extends TimedEvent>, TimedEventHandler<?>>builder() .putAll(getEventHandlers()).put(type, handler).build(), getNumberOfTicks(), getStopModelBuilder(), isIgnoreRedundantHandlers()); }