rename static method

ConfigParams rename(
  1. ConfigParams options,
  2. String fromName,
  3. String toName
)

Renames property if the target name is not used.

  • options configuration options
  • fromName original property name.
  • toName property name to rename to. return updated configuration options

Implementation

static ConfigParams rename(
    ConfigParams options, String fromName, String toName) {
  var fromValue = options.getAsObject(fromName);
  if (fromValue == null) return options;

  var toValue = options.getAsObject(toName);
  if (toValue != null) return options;

  options = ConfigParams.fromValue(options);
  options.setAsObject(toName, fromValue);
  options.remove(fromName);
  return options;
}