DispatcherSettingsBuilder

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. Mappings are applied on top of the full payload: unmapped variables are passed through unchanged, while mapped destinations replace any existing value.

    Basic usage is very simple:

     DispatcherSettingsBuilder().setMappings { mappings in
         mappings.mapFrom("input1", to: "destination1")
         mappings.mapConstant("value", to: "destination2")
     }
    

    For more complex use cases you can leverage the Mappings methods and the JSONObjectPath constructor:

     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")
     }
    

    Declaration

    Swift

    public func setMappings(_ mappingsSetup: @escaping (M) -> Void) -> Self

    Parameters

    mappingsSetup

    A closure that configures the Mappings instance to be applied to each Dispatch before sending it to the Dispatcher.