001/*
002 * JDrupes Builder
003 * Copyright (C) 2026 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.mvnrepo;
020
021import java.nio.file.Path;
022import java.util.List;
023import org.eclipse.aether.repository.RemoteRepository;
024import org.jdrupes.builder.api.ResourceType;
025import org.jdrupes.builder.java.DefaultJarFile;
026import org.jdrupes.builder.java.JarFile;
027import static org.jdrupes.builder.mvnrepo.MvnRepoTypes.MvnRepoResourceType;
028
029/// The default implementation of a [MvnRepoJarFile].
030///
031public class DefaultMvnRepoJarFile extends DefaultJarFile
032        implements MvnRepoJarFile {
033
034    private final MvnRepoResource resource;
035    private final List<RemoteRepository> repositories;
036
037    /// Initializes a new instance with the given values.
038    ///
039    /// @param type the type
040    /// @param repositories the repositories
041    /// @param coordinates the coordinates
042    /// @param path the path
043    ///
044    public DefaultMvnRepoJarFile(ResourceType<? extends JarFile> type,
045            List<RemoteRepository> repositories, String coordinates,
046            Path path) {
047        super(type, path);
048        this.repositories = repositories;
049        resource = new DefaultMvnRepoResource(MvnRepoResourceType, coordinates);
050    }
051
052    @Override
053    public List<RemoteRepository> repositories() {
054        return repositories;
055    }
056
057    @Override
058    public MvnRepoResource reference() {
059        return resource;
060    }
061}