OptionsResolver

A helper class to parameters from “options” configuration section.

Description

The OptionsResolver class can be use to obtain all the parameters under the section “options” from a ConfigfParams object. It has a single method called “resolve”.

Static methods

Resolve

Resolves an “options” configuration section from component configuration parameters.

public static ConfigParams resolve(ConfigParams config, boolean configAsDefault = true)

  • config: ConfigParams - configuration parameters
  • configAsDefault: bool - (optional) when set to true the method returns the entire parameter set when the “options” section is not found. Default: false
  • returns: ConfigParams - configuration parameters from “options” section

Examples

var config = ConfigParams.FromTuples(
  "abc.param1", "ABC",
  "options.param1", "ABC",
  "options.param2", 123);

var options = OptionsResolver.Resolve(config);  // Returns {'param1': 'ABC', 'param2': '123'}

// If the configuration doesn't contain an "options" section, it returns an empty ConfigParams object.
config = ConfigParams.FromTuples(
          "section1.key1", "AAA",
          "section1.key2", 123,
          );
options = OptionsResolver.Resolve(config);  // Returns {}