/** * Creates a new {@code ConfigurationBuilderEvent} based on the passed in * event, but with the source changed to this builder. This method is called * when an event was received from a managed builder. In this case, the * event has to be passed to the builder listeners registered at this * object, but with the correct source property. * * @param event the event received from a managed builder * @return the event to be propagated */ private ConfigurationBuilderEvent createEventWithChangedSource( final ConfigurationBuilderEvent event) { if (ConfigurationBuilderResultCreatedEvent.RESULT_CREATED.equals(event .getEventType())) { return new ConfigurationBuilderResultCreatedEvent(this, ConfigurationBuilderResultCreatedEvent.RESULT_CREATED, ((ConfigurationBuilderResultCreatedEvent) event) .getConfiguration()); } @SuppressWarnings("unchecked") final // This is safe due to the constructor of ConfigurationBuilderEvent EventType<? extends ConfigurationBuilderEvent> type = (EventType<? extends ConfigurationBuilderEvent>) event .getEventType(); return new ConfigurationBuilderEvent(this, type); }