All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.javadpkg.impl.SharedLibrariesImpl Maven / Gradle / Ivy

/*
 * dpkg - Debian Package library and the Debian Package Maven plugin
 * (c) Copyright 2016 Gerrit Hohl
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package net.sourceforge.javadpkg.impl;

import java.util.ArrayList;
import java.util.List;

import net.sourceforge.javadpkg.SharedLibraries;
import net.sourceforge.javadpkg.control.PackageDependency;


/**
 * 

* A {@link SharedLibraries} implementation. *

* * @author Gerrit Hohl ([email protected]) * @version 1.0, 10.01.2016 by Gerrit Hohl */ public class SharedLibrariesImpl implements SharedLibraries { /** The shared libraries. */ private List sharedLibraries; /** *

* Creates shared libraries. *

*/ public SharedLibrariesImpl() { super(); this.sharedLibraries = new ArrayList<>(); } /** *

* Adds a shared library. *

* * @param type * The type (optional). * @param libraryName * The name of the library. * @param version * The version. * @param dependencies * The dependencies. * @throws IllegalArgumentException * If any of the non-optional parameters are null. */ public void addSharedLibrary(String type, String libraryName, String version, List dependencies) { SharedLibrary sharedLibrary; if (libraryName == null) throw new IllegalArgumentException("Argument libraryName is null."); if (version == null) throw new IllegalArgumentException("Argument version is null."); if (dependencies == null) throw new IllegalArgumentException("Argument dependencies is null."); sharedLibrary = new SharedLibrary(type, libraryName, version, dependencies); this.sharedLibraries.add(sharedLibrary); } @Override public String getText() { StringBuilder sb; sb = new StringBuilder(); for (SharedLibrary lib : this.sharedLibraries) { if (sb.length() > 0) { sb.append('\n'); } if (lib.getType() != null) { sb.append(lib.getType()); sb.append(':'); } sb.append(' '); sb.append(lib.getLibraryName()); sb.append(' '); sb.append(lib.getVersion()); sb.append(' '); // TODO Implement getText() method (need a PackageDependencyTransformer). } return sb.toString(); } /* ********************************************************************** * ********************************************************************** * ********************************************************************** * ********************************************************************** * ********************************************************************** */ /** *

* A shared library. *

* * @author Gerrit Hohl ([email protected]) * @version 1.0, 10.01.2016 by Gerrit Hohl */ private class SharedLibrary { /** The type (optional). */ private String type; /** The name of the library. */ private String libraryName; /** The version. */ private String version; /** The dependencies. */ private List dependencies; /** *

* Creates a shared library. *

* * @param type * The type (optional). * @param libraryName * The name of the library. * @param version * The version. * @param dependencies * The dependencies. */ public SharedLibrary(String type, String libraryName, String version, List dependencies) { super(); this.type = type; this.libraryName = libraryName; this.version = version; this.dependencies = new ArrayList<>(dependencies); } /** *

* Returns the type. *

* * @return The type or null, if no type is specified. */ public String getType() { return this.type; } /** *

* Returns the name of the library. *

* * @return The name. */ public String getLibraryName() { return this.libraryName; } /** *

* Returns the version. *

* * @return The version. */ public String getVersion() { return this.version; } /** *

* Returns the dependencies. *

* * @return The dependencies. */ public List getDependencies() { return (new ArrayList<>(this.dependencies)); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy