// Path: src/main/java/org/terasology/launcher/model/Build.java
// public enum Build {
//     STABLE,
//     NIGHTLY
// }
// 
// Path: src/main/java/org/terasology/launcher/model/GameRelease.java
// public class GameRelease {
//     final GameIdentifier id;
//     final ReleaseMetadata releaseMetadata;
//     final URL url;
// 
//     public GameRelease(GameIdentifier id, URL url, ReleaseMetadata releaseMetadata) {
//         this.id = id;
//         this.url = url;
//         this.releaseMetadata = releaseMetadata;
//     }
// 
//     public GameIdentifier getId() {
//         return id;
//     }
// 
//     public URL getUrl() {
//         return url;
//     }
// 
//     /**
//      * The changelog associated with the game release
//      */
//     public String getChangelog() {
//         return releaseMetadata.getChangelog();
//     }
// 
//     public Date getTimestamp() {
//         return releaseMetadata.getTimestamp();
//     }
// 
//     @Override
//     public String toString() {
//         return id.getDisplayVersion();
//     }
// }
// 
// Path: src/main/java/org/terasology/launcher/model/Profile.java
// public enum Profile {
//     OMEGA,
//     ENGINE
// }


import com.google.common.collect.Sets;
import com.google.gson.Gson;
import org.terasology.launcher.model.Build;
import org.terasology.launcher.model.GameRelease;
import org.terasology.launcher.model.Profile;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.launcher.repositories;



public class RepositoryManager {

    private final Set<GameRelease> releases;

    public RepositoryManager() {
        JenkinsClient client = new JenkinsClient(new Gson());

        ReleaseRepository omegaNightly = new JenkinsRepositoryAdapter(Profile.OMEGA, Build.NIGHTLY, client);
        ReleaseRepository github = new GithubRepositoryAdapter();

        Set<ReleaseRepository> all = Sets.newHashSet(github, omegaNightly);

        releases = fetchReleases(all);
    }

    private Set<GameRelease> fetchReleases(final Set<ReleaseRepository> repositories) {
        return repositories.parallelStream()
                .map(ReleaseRepository::fetchReleases)
                .flatMap(List::stream)
                .collect(Collectors.toSet());
    }

    public Set<GameRelease> getReleases() {
// Path: src/main/java/org/terasology/launcher/model/Build.java
// public enum Build {
//     STABLE,
//     NIGHTLY
// }
// 
// Path: src/main/java/org/terasology/launcher/model/GameRelease.java
// public class GameRelease {
//     final GameIdentifier id;
//     final ReleaseMetadata releaseMetadata;
//     final URL url;
// 
//     public GameRelease(GameIdentifier id, URL url, ReleaseMetadata releaseMetadata) {
//         this.id = id;
//         this.url = url;
//         this.releaseMetadata = releaseMetadata;
//     }
// 
//     public GameIdentifier getId() {
//         return id;
//     }
// 
//     public URL getUrl() {
//         return url;
//     }
// 
//     /**
//      * The changelog associated with the game release
//      */
//     public String getChangelog() {
//         return releaseMetadata.getChangelog();
//     }
// 
//     public Date getTimestamp() {
//         return releaseMetadata.getTimestamp();
//     }
// 
//     @Override
//     public String toString() {
//         return id.getDisplayVersion();
//     }
// }
// 
// Path: src/main/java/org/terasology/launcher/model/Profile.java
// public enum Profile {
//     OMEGA,
//     ENGINE
// }


// Path: src/main/java/org/terasology/launcher/repositories/RepositoryManager.java
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import org.terasology.launcher.model.Build;
import org.terasology.launcher.model.GameRelease;
import org.terasology.launcher.model.Profile;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.launcher.repositories;



public class RepositoryManager {

    private final Set<GameRelease> releases;

    public RepositoryManager() {
        JenkinsClient client = new JenkinsClient(new Gson());

        ReleaseRepository omegaNightly = new JenkinsRepositoryAdapter(Profile.OMEGA, Build.NIGHTLY, client);
        ReleaseRepository github = new GithubRepositoryAdapter();

        Set<ReleaseRepository> all = Sets.newHashSet(github, omegaNightly);

        releases = fetchReleases(all);
    }

    private Set<GameRelease> fetchReleases(final Set<ReleaseRepository> repositories) {
        return repositories.parallelStream()
                .map(ReleaseRepository::fetchReleases)
                .flatMap(List::stream)
                .collect(Collectors.toSet());
    }

    public Set<GameRelease> getReleases() {
        return releases;