class DefaultModelProcessor implements ModelProcessor {

    private final Collection<ModelParser> modelParsers;
    private final ModelLocator modelLocator;
    private final ModelReader modelReader;

    @Inject
    public DefaultModelProcessor(List<ModelParser> modelParsers, ModelLocator modelLocator, ModelReader modelReader) {
        this.modelParsers = modelParsers;
        this.modelLocator = modelLocator;
        this.modelReader = modelReader;
    }

    @Deprecated
    @Override
    public File locatePom(File projectDirectory) {
        return locatePom(projectDirectory.toPath()).toFile();
    }

    @Override
    public Path locatePom(Path projectDirectory) {
        // Note that the ModelProcessor#locatePom never returns null
        // while the ModelParser#locatePom needs to return an existing path!
        Path pom = modelParsers.stream()
                .map(m -> m.locate(projectDirectory)
                        .map(org.apache.maven.api.services.Source::getPath)
                        .orElse(null))
                .filter(Objects::nonNull)
                .findFirst()
                .orElseGet(() -> modelLocator.locatePom(projectDirectory));
        if (!pom.equals(projectDirectory) && !pom.getParent().equals(projectDirectory)) {
            throw new IllegalArgumentException("The POM found does not belong to the given directory: " + pom);
        }
        return pom;
    }

    @Deprecated
    @Override
    public File locateExistingPom(File projectDirectory) {
        Path path = locateExistingPom(projectDirectory.toPath());
        return path != null ? path.toFile() : null;
    }

    @Override
    public Path locateExistingPom(Path projectDirectory) {
        // Note that the ModelProcessor#locatePom never returns null
        // while the ModelParser#locatePom needs to return an existing path!
        Path pom = modelParsers.stream()
                .map(m -> m.locate(projectDirectory)
                        .map(org.apache.maven.api.services.Source::getPath)
                        .orElse(null))
                .filter(Objects::nonNull)
                .findFirst()
                .orElseGet(() -> modelLocator.locateExistingPom(projectDirectory));
        if (pom != null && !pom.equals(projectDirectory) && !pom.getParent().equals(projectDirectory)) {
            throw new IllegalArgumentException("The POM found does not belong to the given directory: " + pom);
        }
        return pom;
    }

    protected org.apache.maven.api.model.Model read(
            Path pomFile, InputStream input, Reader reader, Map<String, ?> options) throws IOException {<FILL_FUNCTION_BODY>}

    private org.apache.maven.api.model.Model readXmlModel(
            Path pomFile, InputStream input, Reader reader, Map<String, ?> options) throws IOException {
        if (pomFile != null) {
            return modelReader.read(pomFile, options).getDelegate();
        } else if (input != null) {
            return modelReader.read(input, options).getDelegate();
        } else {
            return modelReader.read(reader, options).getDelegate();
        }
    }

    @Deprecated
    @Override
    public org.apache.maven.model.Model read(File file, Map<String, ?> options) throws IOException {
        Objects.requireNonNull(file, "file cannot be null");
        return read(file.toPath(), options);
    }

    @Override
    public org.apache.maven.model.Model read(Path path, Map<String, ?> options) throws IOException {
        Objects.requireNonNull(path, "path cannot be null");
        org.apache.maven.api.model.Model model = read(path, null, null, options);
        return new org.apache.maven.model.Model(model);
    }

    @Override
    public org.apache.maven.model.Model read(InputStream input, Map<String, ?> options) throws IOException {
        Objects.requireNonNull(input, "input cannot be null");
        try (InputStream in = input) {
            org.apache.maven.api.model.Model model = read(null, in, null, options);
            return new org.apache.maven.model.Model(model);
        } catch (ModelParserException e) {
            throw new ModelParseException("Unable to read model: " + e, e.getLineNumber(), e.getColumnNumber(), e);
        }
    }

    @Override
    public org.apache.maven.model.Model read(Reader reader, Map<String, ?> options) throws IOException {
        Objects.requireNonNull(reader, "reader cannot be null");
        try (Reader r = reader) {
            org.apache.maven.api.model.Model model = read(null, null, r, options);
            return new org.apache.maven.model.Model(model);
        }
    }
}

        Source source = (Source) options.get(ModelProcessor.SOURCE);
        if (pomFile == null && source instanceof org.apache.maven.building.FileSource) {
            pomFile = ((org.apache.maven.building.FileSource) source).getPath();
        }
        if (pomFile != null) {
            Path projectDirectory = pomFile.getParent();
            List<ModelParserException> exceptions = new ArrayList<>();
            for (ModelParser parser : modelParsers) {
                try {
                    Optional<Model> model = parser.locateAndParse(projectDirectory, options);
                    if (model.isPresent()) {
                        return model.get().withPomFile(pomFile);
                    }
                } catch (ModelParserException e) {
                    exceptions.add(e);
                }
            }
            try {
                return readXmlModel(pomFile, null, null, options);
            } catch (IOException e) {
                exceptions.forEach(e::addSuppressed);
                throw e;
            }
        } else {
            return readXmlModel(pomFile, input, reader, options);
        }
    
<no_super_class>