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. When defined only mapped variables will be passed to the Dispatcher.

    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 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")
         mappings.keep(JSONPath["container"]["inputToMapAsIs"])
     }
    

    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.