class DefaultSettingsBuilder implements SettingsBuilder {

    private final org.apache.maven.internal.impl.DefaultSettingsBuilder builder;
    private final org.apache.maven.internal.impl.DefaultSettingsXmlFactory settingsXmlFactory;

    @Inject
    public DefaultSettingsBuilder(
            org.apache.maven.internal.impl.DefaultSettingsBuilder builder,
            org.apache.maven.internal.impl.DefaultSettingsXmlFactory settingsXmlFactory) {
        this.builder = builder;
        this.settingsXmlFactory = settingsXmlFactory;
    }

    @Override
    public SettingsBuildingResult build(SettingsBuildingRequest request) throws SettingsBuildingException {

        try {
            SettingsBuilderResult result = builder.build(SettingsBuilderRequest.builder()
                    .session((Session) java.lang.reflect.Proxy.newProxyInstance(
                            Session.class.getClassLoader(),
                            new Class[] {Session.class},
                            (Object proxy, Method method, Object[] args) -> {
                                if ("getSystemProperties".equals(method.getName())) {
                                    return request.getSystemProperties().entrySet().stream()
                                            .collect(Collectors.toMap(
                                                    e -> e.getKey().toString(),
                                                    e -> e.getValue().toString()));
                                } else if ("getUserProperties".equals(method.getName())) {
                                    return request.getUserProperties().entrySet().stream()
                                            .collect(Collectors.toMap(
                                                    e -> e.getKey().toString(),
                                                    e -> e.getValue().toString()));
                                } else if ("getService".equals(method.getName())) {
                                    if (args[0] == SettingsXmlFactory.class) {
                                        return settingsXmlFactory;
                                    }
                                }
                                return null;
                            }))
                    .globalSettingsSource(toSource(request.getGlobalSettingsFile(), request.getGlobalSettingsSource()))
                    .projectSettingsSource(
                            toSource(request.getProjectSettingsFile(), request.getProjectSettingsSource()))
                    .userSettingsSource(toSource(request.getUserSettingsFile(), request.getUserSettingsSource()))
                    .build());

            return new DefaultSettingsBuildingResult(
                    new Settings(result.getEffectiveSettings()), convert(result.getProblems()));
        } catch (SettingsBuilderException e) {
            throw new SettingsBuildingException(convert(e.getProblems()));
        }
    }

    private org.apache.maven.api.services.Source toSource(File file, Source source) {<FILL_FUNCTION_BODY>}

    private List<SettingsProblem> convert(List<BuilderProblem> problems) {
        return problems.stream().map(this::convert).toList();
    }

    private SettingsProblem convert(BuilderProblem problem) {
        return new DefaultSettingsProblem(
                problem.getMessage(),
                SettingsProblem.Severity.valueOf(problem.getSeverity().name()),
                problem.getSource(),
                problem.getLineNumber(),
                problem.getColumnNumber(),
                problem.getException());
    }
}

        if (file != null && file.exists()) {
            return org.apache.maven.api.services.Source.fromPath(file.toPath());
        } else if (source instanceof FileSource fs) {
            return org.apache.maven.api.services.Source.fromPath(fs.getPath());
        } else if (source != null) {
            return new org.apache.maven.api.services.Source() {
                @Override
                public Path getPath() {
                    return null;
                }

                @Override
                public InputStream openStream() throws IOException {
                    return source.getInputStream();
                }

                @Override
                public String getLocation() {
                    return source.getLocation();
                }

                @Override
                public org.apache.maven.api.services.Source resolve(String relative) {
                    return null;
                }
            };
        } else {
            return null;
        }
    
<no_super_class>