/** * Returns an {@link EventProcessor} by the given {@code processingGroup} if present, matching the given * {@code expectedType}. * * @param processingGroup a {@link String} specifying the processing group of an {@link EventProcessor} * @param expectedType the type of the {@link EventProcessor} to return * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} referencing the {@link EventProcessor}, if present and of expected type */ default <T extends EventProcessor> Optional<T> eventProcessorByProcessingGroup(String processingGroup, Class<T> expectedType) { return eventProcessorByProcessingGroup(processingGroup).filter(expectedType::isInstance) .map(expectedType::cast); }
/** * Obtains an Saga {@link EventProcessor} implementation for the given {@code sagaType}. * * @param sagaType the type of Saga for which to get the Event Processor * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} specifying whether an {@link EventProcessor} for the given {@link SagaConfiguration} * exists */ default <T extends EventProcessor> Optional<T> sagaEventProcessor(Class<?> sagaType) { return eventProcessorByProcessingGroup(sagaProcessingGroup(sagaType)); }
/** * Returns the Event Processor by the given {@code processingGroup}, if present and of the given {@code * expectedType}. * * @param processingGroup The name of the processing group * @param expectedType The type of processor expected * @param <T> The type of processor expected * @return an Optional referencing the processor, if present and of expected type */ public <T extends EventProcessor> Optional<T> eventProcessorByProcessingGroup(String processingGroup, Class<T> expectedType) { return eventProcessorByProcessingGroup(processingGroup).filter(expectedType::isInstance) .map(expectedType::cast); }
/** * Returns an {@link EventProcessor} by the given {@code processingGroup} if present, matching the given * {@code expectedType}. * * @param processingGroup a {@link String} specifying the processing group of an {@link EventProcessor} * @param expectedType the type of the {@link EventProcessor} to return * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} referencing the {@link EventProcessor}, if present and of expected type */ default <T extends EventProcessor> Optional<T> eventProcessorByProcessingGroup(String processingGroup, Class<T> expectedType) { return eventProcessorByProcessingGroup(processingGroup).filter(expectedType::isInstance) .map(expectedType::cast); }
/** * Obtains an Saga {@link EventProcessor} implementation for the given {@code sagaType}. * * @param sagaType the type of Saga for which to get the Event Processor * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} specifying whether an {@link EventProcessor} for the given {@link SagaConfiguration} * exists */ default <T extends EventProcessor> Optional<T> sagaEventProcessor(Class<?> sagaType) { return eventProcessorByProcessingGroup(sagaProcessingGroup(sagaType)); }
/** * Returns the processor that processed events for the Saga in this Configuration. * * @return The EventProcessor defined in this Configuration * * @throws IllegalStateException when this configuration hasn't been initialized yet */ public EventProcessor getProcessor() { return eventProcessingConfiguration().eventProcessorByProcessingGroup(processorInfo.getProcessingGroup()) .orElse(null); }