001/*
002 * JDrupes Builder
003 * Copyright (C) 2025 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.builder.api;
020
021import java.io.IOException;
022import java.util.stream.Stream;
023
024/// Defines the methods provided by a launcher.
025///
026public interface Launcher extends AutoCloseable {
027
028    /// Provide the requested resources from the given projects, using
029    /// the context from the root project. The launcher must automatically
030    /// regenerate the root project if [Cleanliness] was requested.
031    ///
032    /// @param <T> the requested type
033    /// @param projects the projects
034    /// @param requested the request
035    /// @return the results
036    ///
037    <T extends Resource> Stream<T> resources(Stream<Project> projects,
038            ResourceRequest<T> requested);
039
040    /// Provide the requested resources from the root project, using
041    /// the context from the root project.
042    ///
043    /// @param <T> the generic type
044    /// @param requested the requested
045    /// @return the stream
046    ///
047    default <T extends Resource> Stream<T>
048            resources(ResourceRequest<T> requested) {
049        return resources(Stream.of(rootProject()), requested);
050    }
051
052    /// Return the root project.
053    ///
054    /// @return the root project
055    ///
056    RootProject rootProject();
057
058    /// Regenerate root project, see [Cleanliness].
059    ///
060    /// @return the root project
061    ///
062    RootProject regenerateRootProject();
063
064    /// Close the launcher. The re-declaration of this method removes
065    /// the [IOException], which is never thrown.
066    ///
067    @Override
068    void close();
069}