DispatcherSettingsBuilder Class Reference
open class DispatcherSettingsBuilder<M> : ModuleSettingsBuilder, RuleModuleSettingsBuilder where M : Mappings
A builder for Dispatcher Settings which adds the possibility to set Rules and JSONOperation<MappingParameters>.
-
Set the mappings for this module.
Mappings will only be used if the module is a
Dispatcher. When defined only mapped variables will be passed to theDispatcher.Basic usage is very simple:
DispatcherSettingsBuilder().setMappings { mappings in mappings.mapFrom("input1", to: "destination1") mappings.mapConstant("value", to: "destination2") mappings.keep("input2") }For more complex use cases you can leverage the
Mappingsmethods and theJSONObjectPathconstructor:DispatcherSettingsBuilder().setMappings { mappings in mappings.mapFrom(JSONPath["container"]["input1"], to: JSONPath["resultContainer"]["destination"]) .ifValueEquals("value") mappings.mapConstant("value", to: JSONPath["resultContainer"]["destination"]) .ifValueIn(JSONPath["container"]["input2"], equals: "targetValue") mappings.keep(JSONPath["container"]["inputToMapAsIs"]) }Declaration
Swift
public func setMappings(_ mappingsSetup: @escaping (M) -> Void) -> SelfParameter Description mappingsSetupA closure that configures the
Mappingsinstance to be applied to eachDispatchbefore sending it to theDispatcher.