getSection method

ConfigParams getSection(
  1. String section
)

Gets parameters from specific section stored in this ConfigMap. The section name is removed from parameter keys.

  • section name of the section to retrieve configuration parameters from. Returns all configuration parameters that belong to the section named 'section'.

Implementation

ConfigParams getSection(String section) {
  var result = ConfigParams();
  var prefix = section + '.';

  for (var key in getKeys()) {
    // Prevents exception on the next line
    if (key.length < prefix.length) continue;

    // Perform case sensitive match
    var keyPrefix = key.substring(0, prefix.length);
    if (keyPrefix == prefix) {
      var name = key.substring(prefix.length);
      result.put(name, this[key]);
    }
  }

  return result;
}