View Javadoc
1   /*
2    * dpkg - Debian Package library and the Debian Package Maven plugin
3    * (c) Copyright 2015 Gerrit Hohl
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18   */
19  package net.sourceforge.javadpkg.control;
20  
21  import java.util.List;
22  
23  /**
24   * <p>
25   * The dependency of a package to other packages.
26   * </p>
27   * <p>
28   * See <a href="https://www.debian.org/doc/debian-policy/ch-relationships.html">
29   * Chapter 7 - Declaring relationships between packages</a> for further
30   * information.
31   * </p>
32   *
33   * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
34   * @version <b>1.0</b>, 31.12.2015 by Gerrit Hohl
35   */
36  public interface PackageDependency {
37  	
38  	
39  	/*
40  	 * TODO Split that interface later in a super interface for package dependencies and a sub interface for normal
41  	 * package dependencies (package, relation operator, version) and conditional package dependencies (condition and list
42  	 * of normal package dependencies).
43  	 */
44  	
45  	
46  	/**
47  	 * <p>
48  	 * A condition for a package dependency.
49  	 * </p>
50  	 *
51  	 * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
52  	 * @version <b>1.0</b>, 03.01.2016 by Gerrit Hohl
53  	 */
54  	public enum Condition {
55  		/** An or condition. */
56  		OR
57  	}
58  
59  
60  	/**
61  	 * <p>
62  	 * Returns the flag if this package dependency is a condition.
63  	 * </p>
64  	 * <p>
65  	 * If the package dependency is a condition the {@link #getCondition()} and
66  	 * {@link #getConditionPackageDependencies()} methods must be used.
67  	 * Otherwise the {@link #getPackage()}, {@link #getRelationOperator()} and
68  	 * {@link #getVersion()} methods must be used.
69  	 * </p>
70  	 *
71  	 * @return The flag: <code>true</code>, if this package dependency is a
72  	 *         condition, <code>false</code> otherwise.
73  	 */
74  	boolean isCondition();
75  
76  
77  	/**
78  	 * <p>
79  	 * Returns the condition.
80  	 * </p>
81  	 *
82  	 * @return The condition or <code>null</code>, if this package dependency is
83  	 *         a not a condition.
84  	 * @see #isCondition()
85  	 */
86  	Condition getCondition();
87  
88  
89  	/**
90  	 * <p>
91  	 * Returns the package dependencies for the condition.
92  	 * </p>
93  	 *
94  	 * @return The package dependencies or an empty list, if this package
95  	 *         dependency is a not a condition.
96  	 * @see #isCondition()
97  	 */
98  	List<PackageDependency> getConditionPackageDependencies();
99  	
100 	
101 	/**
102 	 * <p>
103 	 * Returns the name of the package.
104 	 * </p>
105 	 *
106 	 * @return The name or <code>null</code>, if this package dependency is a
107 	 *         condition.
108 	 * @see #isCondition()
109 	 */
110 	PackageName getPackage();
111 
112 
113 	/**
114 	 * <p>
115 	 * Returns the relational operator.
116 	 * </p>
117 	 *
118 	 * @return The relational operator or <code>null</code>, if no version is
119 	 *         specified or this package dependency is a condition.
120 	 * @see #isCondition()
121 	 */
122 	PackageVersionRelationOperator getRelationOperator();
123 
124 
125 	/**
126 	 * <p>
127 	 * Returns the version.
128 	 * </p>
129 	 *
130 	 * @return The version or <code>null</code>, if no version is specified or
131 	 *         this package dependency is a condition.
132 	 * @see #isCondition()
133 	 */
134 	PackageVersion getVersion();
135 
136 
137 }