
com.opencredo.concursus.mapping.events.methods.dispatching.DispatchingEventSourceFactory Maven / Gradle / Ivy
The newest version!
package com.opencredo.concursus.mapping.events.methods.dispatching;
import com.opencredo.concursus.domain.events.sourcing.EventSource;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Binds an {@link EventSource} to create {@link DispatchingEventSource}s for different handler classes.
*/
public final class DispatchingEventSourceFactory {
/**
* Bind the supplied {@link EventSource} and return a factory that creates {@link DispatchingEventSource}s for
* different handler classes.
* @param eventSource The {@link EventSource} to bind.
* @return The constructed {@link DispatchingEventSourceFactory}.
*/
public static DispatchingEventSourceFactory dispatching(EventSource eventSource) {
checkNotNull(eventSource, "eventSource must not be null");
return new DispatchingEventSourceFactory(eventSource);
}
private final EventSource eventSource;
private DispatchingEventSourceFactory(EventSource eventSource) {
this.eventSource = eventSource;
}
/**
* Create a {@link DispatchingEventSource} for the supplied handler class.
* @param handlerClass The handler class to create a {@link DispatchingEventSource} for.
* @param The type of the handler class.
* @return The constructed {@link DispatchingEventSource}.
*/
public DispatchingEventSource dispatchingTo(Class handlerClass) {
return DispatchingEventSource.dispatching(eventSource, handlerClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy