docs: @SuppressWarnings("unchecked")
    protected <T> T map(Config config, String path, String name, Class<T> clazz) {
      T instance = newInstance(config, name, clazz);
  
      // Map config property names to bean properties.
      Map<String, String> propertyNames = new HashMap<>();
      for (Map.Entry<String, ConfigValue> configProp : config.root().entrySet()) {
        String originalName = configProp.getKey();
        String camelName = toCamelCase(originalName);
        // if a setting is in there both as some hyphen name and the camel name,
        // the camel one wins
        if (!propertyNames.containsKey(camelName) || originalName.equals(camelName)) {
          propertyNames.put(camelName, originalName);
        }
      }
  
      // First use setters and then fall back to fields.
      mapSetters(instance, clazz, path, name, propertyNames, config);
      mapFields(instance, clazz, path, name, propertyNames, config);
  
      // If any properties present in the configuration were not found on config beans, throw an exception.
      if (!propertyNames.isEmpty()) {
        checkRemainingProperties(propertyNames.keySet(), describeProperties(instance), toPath(path, name), clazz);
      }
      return instance;
    }