Class UseCaseInvocationBuilder
- java.lang.Object
-
- de.quantummaid.eventmaid.usecases.usecaseadapter.UseCaseInvocationBuilder
-
- All Implemented Interfaces:
BuilderStepBuilder,ExceptionSerializationStep1Builder,FinalStepBuilder,InjectionStepBuilder,InstantiationBuilder,InvokingUseCaseStepBuilder,RequestDeserializationStep1Builder,RequestSerializationStep1Builder,ResponseDeserializationStep1Builder,ResponseSerializationStep1Builder,Step1Builder
public final class UseCaseInvocationBuilder extends Object implements Step1Builder, InstantiationBuilder, RequestDeserializationStep1Builder, RequestSerializationStep1Builder, ResponseSerializationStep1Builder, ExceptionSerializationStep1Builder, ResponseDeserializationStep1Builder, FinalStepBuilder
Fluent interface builder to configure either aUseCaseAdapteror aUseCaseBus.
-
-
Constructor Summary
Constructors Constructor Description UseCaseInvocationBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Step1BuilderanUseCaseAdapter()Starts the configuration of aUseCaseAdapter.static Step1BuilderanUseCaseBus()Starts the configuration of aUseCaseBus.UseCaseBusbuild(MessageBus messageBus)Completes the configuration and creates aUseCaseBusbased on the givenSerializedMessageBus.UseCaseAdapterbuildAsStandaloneAdapter()Completes the configuration and creates aUseCaseAdapter.ResponseSerializationStep1BuilderdeserializeRequestsToUseCaseParametersPerDefault(Demapifier<Object> mapper)Configures the defaultDemapifierthat will be used to deserialize a to a use case parameter if noDemapifierconfigured can be applied.<T> RequestDeserializationStep2Builder<T>deserializeRequestsToUseCaseParametersThat(BiPredicate<Class<?>,Object> filter)Enters a fluent builder that configures aDemapifierthat will be used to deserialize aMapto a use case parameter if the object matches the providedfilter.FinalStepBuilderdeserializeUseCaseResponsesPerDefault(Demapifier<Object> mapper)Configures the defaultDemapifierthat will be used to deserialize a use case response if noDemapifierconfigured matches the response.<T> ResponseDeserializationStep2Builder<T>deserializingUseCaseResponsesOfThat(BiPredicate<Class<?>,Object> filter)Enters a fluent builder that configures aDemapifierthat will be used to deserialize aMapfrom theMessageBusto the return value of the use case invocation, if the object matches the providedfilter.<T> FinalStepBuilderinjectParameterForClass(Class<T> parameterClass, Function<ParameterInjectionInformation,T> injectionFunction)Adds a new parameter injection.<U> Step2Builder<U>invokingUseCase(Class<U> useCaseClass)Adds a new invocation information for a use case of the givenClass.RequestSerializationStep1BuilderobtainingUseCaseInstancesUsing(UseCaseInstantiator useCaseInstantiator)Configures theUseCaseInvocationBuilderto use the givenUseCaseInstantiatorfor each request.ResponseDeserializationStep1BuilderserializingExceptionsByDefaultUsing(Mapifier<Exception> mapper)Configures the defaultMapifierthat will be used to serialize an exception to aMapif noMapifierconfigured underExceptionSerializationStep1Builder.serializingExceptionsThat(Predicate),ExceptionSerializationStep1Builder.serializingExceptionsOfType(Class), etc.ExceptionSerializationStep2Builder<Exception>serializingExceptionsThat(Predicate<Exception> filter)RequestSerializationStep2Builder<Object>serializingUseCaseRequestOntoTheBusMatching(Predicate<Object> filter)Enters a fluent builder that configures aMapifierthat will be used to serialize a use case request onto theMessageBusif the type matches the providedfilter.RequestDeserializationStep1BuilderserializingUseCaseRequestsByDefaultUsing(Mapifier<Object> mapper)Configures the defaultMapifierthat will be used to serialize a use case request if no other serialization can be applied.ExceptionSerializationStep1BuilderserializingUseCaseResponseBackOntoTheBusByDefaultUsing(Mapifier<Object> mapper)Configures the defaultMapifierthat will be used to serialize a use case return value onto theMessageBusif noMapifierconfigured matches the use case return value.ResponseSerializationStep2Builder<Object>serializingUseCaseResponseBackOntoTheBusThat(Predicate<Object> filter)Enters a fluent builder that configures aMapifierthat will be used to serialize a use case return value onto theMessageBusif the use case return value matches the providedfilter.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.ExceptionSerializationStep1Builder
puttingExceptionObjectNamedAsExceptionIntoResponseMapByDefault, respondingWithAWrappingMissingExceptionSerializationExceptionByDefault, serializingExceptionsOfType
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.InstantiationBuilder
obtainingUseCaseInstancesUsingTheZeroArgumentConstructor
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.RequestDeserializationStep1Builder
deserializingRequestsToUseCaseParametersOfType, throwAnExceptionByDefaultIfNoUseCaseRequestDeserializationCanBeApplied
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.RequestSerializationStep1Builder
serializingUseCaseRequestOntoTheBusOfType, serializingUseCaseRequestOntoTheBusOfTypeVoid, throwingAnExceptionByDefaultIfNoRequestSerializationCanBeApplied
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.ResponseDeserializationStep1Builder
deserializingUseCaseResponsesOfType, deserializingUseCaseResponsesThat, throwAnExceptionByDefaultIfNoResponseDeserializationCanBeApplied
-
Methods inherited from interface de.quantummaid.eventmaid.usecases.building.ResponseSerializationStep1Builder
serializingResponseObjectsOfTypeVoid, serializingUseCaseResponseBackOntoTheBusOfType, throwingAnExceptionByDefaultIfNoResponseSerializationCanBeApplied
-
-
-
-
Method Detail
-
anUseCaseAdapter
public static Step1Builder anUseCaseAdapter()
Starts the configuration of aUseCaseAdapter.- Returns:
- the first step in the fluent builder interface
-
anUseCaseBus
public static Step1Builder anUseCaseBus()
Starts the configuration of aUseCaseBus.- Returns:
- the first step in the fluent builder interface
-
invokingUseCase
public <U> Step2Builder<U> invokingUseCase(Class<U> useCaseClass)
Description copied from interface:InvokingUseCaseStepBuilderAdds a new invocation information for a use case of the givenClass.- Specified by:
invokingUseCasein interfaceInvokingUseCaseStepBuilder- Type Parameters:
U- the type of the use case- Parameters:
useCaseClass- theClassof the use case- Returns:
- the next step in the fluent builder interface
-
obtainingUseCaseInstancesUsing
public RequestSerializationStep1Builder obtainingUseCaseInstancesUsing(UseCaseInstantiator useCaseInstantiator)
Description copied from interface:InstantiationBuilderConfigures theUseCaseInvocationBuilderto use the givenUseCaseInstantiatorfor each request.- Specified by:
obtainingUseCaseInstancesUsingin interfaceInstantiationBuilder- Parameters:
useCaseInstantiator- theUseCaseInstantiatorto invoke- Returns:
- the next step in the fluent builder interface
-
serializingUseCaseRequestOntoTheBusMatching
public RequestSerializationStep2Builder<Object> serializingUseCaseRequestOntoTheBusMatching(Predicate<Object> filter)
Description copied from interface:RequestSerializationStep1BuilderEnters a fluent builder that configures aMapifierthat will be used to serialize a use case request onto theMessageBusif the type matches the providedfilter.- Specified by:
serializingUseCaseRequestOntoTheBusMatchingin interfaceRequestSerializationStep1Builder- Parameters:
filter- aPredicatethat returns true if theMapifiershould be used on the respective use case request- Returns:
- the next step in the fluent builder
-
serializingUseCaseRequestsByDefaultUsing
public RequestDeserializationStep1Builder serializingUseCaseRequestsByDefaultUsing(Mapifier<Object> mapper)
Description copied from interface:RequestSerializationStep1BuilderConfigures the defaultMapifierthat will be used to serialize a use case request if no other serialization can be applied.- Specified by:
serializingUseCaseRequestsByDefaultUsingin interfaceRequestSerializationStep1Builder- Parameters:
mapper- aMapifier- Returns:
- the next step in the fluent builder
-
deserializeRequestsToUseCaseParametersThat
public <T> RequestDeserializationStep2Builder<T> deserializeRequestsToUseCaseParametersThat(BiPredicate<Class<?>,Object> filter)
Description copied from interface:RequestDeserializationStep1BuilderEnters a fluent builder that configures aDemapifierthat will be used to deserialize aMapto a use case parameter if the object matches the providedfilter.- Specified by:
deserializeRequestsToUseCaseParametersThatin interfaceRequestDeserializationStep1Builder- Type Parameters:
T- the type of the use case response- Parameters:
filter- aBiPredicatethat returns true if theDemapifiershould be used on the respective http request- Returns:
- the next step in the fluent builder
-
deserializeRequestsToUseCaseParametersPerDefault
public ResponseSerializationStep1Builder deserializeRequestsToUseCaseParametersPerDefault(Demapifier<Object> mapper)
Description copied from interface:RequestDeserializationStep1BuilderConfigures the defaultDemapifierthat will be used to deserialize a to a use case parameter if noDemapifierconfigured can be applied.- Specified by:
deserializeRequestsToUseCaseParametersPerDefaultin interfaceRequestDeserializationStep1Builder- Parameters:
mapper- aDemapifier- Returns:
- the next step in the fluent builder
-
serializingUseCaseResponseBackOntoTheBusThat
public ResponseSerializationStep2Builder<Object> serializingUseCaseResponseBackOntoTheBusThat(Predicate<Object> filter)
Description copied from interface:ResponseSerializationStep1BuilderEnters a fluent builder that configures aMapifierthat will be used to serialize a use case return value onto theMessageBusif the use case return value matches the providedfilter.- Specified by:
serializingUseCaseResponseBackOntoTheBusThatin interfaceResponseSerializationStep1Builder- Parameters:
filter- aPredicatethat returns true if theMapifiershould be used on the respective use case response- Returns:
- the next step in the fluent builder
-
serializingUseCaseResponseBackOntoTheBusByDefaultUsing
public ExceptionSerializationStep1Builder serializingUseCaseResponseBackOntoTheBusByDefaultUsing(Mapifier<Object> mapper)
Description copied from interface:ResponseSerializationStep1BuilderConfigures the defaultMapifierthat will be used to serialize a use case return value onto theMessageBusif noMapifierconfigured matches the use case return value.- Specified by:
serializingUseCaseResponseBackOntoTheBusByDefaultUsingin interfaceResponseSerializationStep1Builder- Parameters:
mapper- aMapifier- Returns:
- the next step in the fluent builder
-
serializingExceptionsThat
public ExceptionSerializationStep2Builder<Exception> serializingExceptionsThat(Predicate<Exception> filter)
Description copied from interface:ExceptionSerializationStep1BuilderEnters a fluent builder that configures aMapifierthat will be used to serialize an exception thrown by a use case to aMapif the exception matches the providedfilter.- Specified by:
serializingExceptionsThatin interfaceExceptionSerializationStep1Builder- Parameters:
filter- aPredicatethat returns true if theMapifiershould be used on the respective exception- Returns:
- the next step in the fluent builder
-
serializingExceptionsByDefaultUsing
public ResponseDeserializationStep1Builder serializingExceptionsByDefaultUsing(Mapifier<Exception> mapper)
Description copied from interface:ExceptionSerializationStep1BuilderConfigures the defaultMapifierthat will be used to serialize an exception to aMapif noMapifierconfigured underExceptionSerializationStep1Builder.serializingExceptionsThat(Predicate),ExceptionSerializationStep1Builder.serializingExceptionsOfType(Class), etc. matches the exception.- Specified by:
serializingExceptionsByDefaultUsingin interfaceExceptionSerializationStep1Builder- Parameters:
mapper- aMapifier- Returns:
- the next step in the fluent builder
-
deserializingUseCaseResponsesOfThat
public <T> ResponseDeserializationStep2Builder<T> deserializingUseCaseResponsesOfThat(BiPredicate<Class<?>,Object> filter)
Description copied from interface:ResponseDeserializationStep1BuilderEnters a fluent builder that configures aDemapifierthat will be used to deserialize aMapfrom theMessageBusto the return value of the use case invocation, if the object matches the providedfilter.- Specified by:
deserializingUseCaseResponsesOfThatin interfaceResponseDeserializationStep1Builder- Type Parameters:
T- the type of the use case response- Parameters:
filter- aBiPredicatethat returns true if theDemapifiershould be used- Returns:
- the next step in the fluent builder
-
deserializeUseCaseResponsesPerDefault
public FinalStepBuilder deserializeUseCaseResponsesPerDefault(Demapifier<Object> mapper)
Description copied from interface:ResponseDeserializationStep1BuilderConfigures the defaultDemapifierthat will be used to deserialize a use case response if noDemapifierconfigured matches the response.- Specified by:
deserializeUseCaseResponsesPerDefaultin interfaceResponseDeserializationStep1Builder- Parameters:
mapper- aDemapifier- Returns:
- the next step in the fluent builder
-
injectParameterForClass
public <T> FinalStepBuilder injectParameterForClass(Class<T> parameterClass, Function<ParameterInjectionInformation,T> injectionFunction)
Description copied from interface:InjectionStepBuilderAdds a new parameter injection.Calling this method again for the same class overwrites previous calls.
- Specified by:
injectParameterForClassin interfaceInjectionStepBuilder- Type Parameters:
T- the type of the class- Parameters:
parameterClass- the class of the paramter to injectinjectionFunction- a function to inject the value based on theParameterInjectionInformation- Returns:
- the next step in the fluent builder interface
-
build
public UseCaseBus build(MessageBus messageBus)
Description copied from interface:BuilderStepBuilderCompletes the configuration and creates aUseCaseBusbased on the givenSerializedMessageBus.- Specified by:
buildin interfaceBuilderStepBuilder- Parameters:
messageBus- theMessageBusto use- Returns:
- the newly created
UseCaseBus
-
buildAsStandaloneAdapter
public UseCaseAdapter buildAsStandaloneAdapter()
Description copied from interface:BuilderStepBuilderCompletes the configuration and creates aUseCaseAdapter.- Specified by:
buildAsStandaloneAdapterin interfaceBuilderStepBuilder- Returns:
- the newly created
UseCaseAdapter
-
-