View Javadoc
1   /*
2    * dpkg - Debian Package library and the Debian Package Maven plugin
3    * (c) Copyright 2016 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.impl;
20  
21  import java.util.ArrayList;
22  import java.util.Date;
23  import java.util.List;
24  
25  import net.sourceforge.javadpkg.ChangeLogUrgency;
26  import net.sourceforge.javadpkg.ChangeLogVersionEntry;
27  import net.sourceforge.javadpkg.ChangeLogVersionEntryDetail;
28  import net.sourceforge.javadpkg.control.PackageMaintainer;
29  import net.sourceforge.javadpkg.control.PackageName;
30  import net.sourceforge.javadpkg.control.PackageVersion;
31  
32  
33  /**
34   * <p>
35   * A {@link ChangeLogVersionEntry} implementation.
36   * </p>
37   *
38   * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
39   * @version <b>1.0</b>, 04.05.2016 by Gerrit Hohl
40   */
41  public class ChangeLogVersionEntryImpl implements ChangeLogVersionEntry {
42  	
43  	
44  	/** The name of the package. */
45  	private PackageName							packageName;
46  	/** The version. */
47  	private PackageVersion						version;
48  	/** The distributions. */
49  	private List<String>						distributions;
50  	/** The urgency of the version. */
51  	private ChangeLogUrgency					urgency;
52  	/** The details. */
53  	private List<ChangeLogVersionEntryDetail>	details;
54  	/** The maintainer. */
55  	private PackageMaintainer					maintainer;
56  	/** The date. */
57  	private Date								date;
58  
59  
60  	/**
61  	 * <p>
62  	 * Creates an entry.
63  	 * </p>
64  	 */
65  	public ChangeLogVersionEntryImpl() {
66  		super();
67  		
68  		this.packageName = null;
69  		this.version = null;
70  		this.distributions = new ArrayList<>();
71  		this.urgency = null;
72  		this.details = new ArrayList<>();
73  		this.maintainer = null;
74  		this.date = null;
75  	}
76  	
77  	
78  	@Override
79  	public PackageName getPackage() {
80  		return this.packageName;
81  	}
82  	
83  	
84  	/**
85  	 * <p>
86  	 * Sets the name of the package.
87  	 * </p>
88  	 *
89  	 * @param packageName
90  	 *            The name.
91  	 */
92  	public void setPackageName(PackageName packageName) {
93  		this.packageName = packageName;
94  	}
95  
96  
97  	@Override
98  	public PackageVersion getVersion() {
99  		return this.version;
100 	}
101 	
102 	
103 	/**
104 	 * <p>
105 	 * Sets the version.
106 	 * </p>
107 	 *
108 	 * @param version
109 	 */
110 	public void setVersion(PackageVersion version) {
111 		this.version = version;
112 	}
113 
114 
115 	@Override
116 	public List<String> getDistributions() {
117 		return (new ArrayList<>(this.distributions));
118 	}
119 	
120 	
121 	/**
122 	 * <p>
123 	 * Sets the distributions.
124 	 * </p>
125 	 *
126 	 * @param distributions
127 	 *            The distributions.
128 	 */
129 	public void setDistributions(List<String> distributions) {
130 		if (distributions == null) {
131 			this.distributions = new ArrayList<>();
132 		} else {
133 			this.distributions = new ArrayList<>(distributions);
134 		}
135 	}
136 
137 
138 	@Override
139 	public ChangeLogUrgency getUrgency() {
140 		return this.urgency;
141 	}
142 
143 
144 	/**
145 	 * <p>
146 	 * Sets the urgency.
147 	 * </p>
148 	 *
149 	 * @param urgency
150 	 *            The urgency.
151 	 */
152 	public void setUrgency(ChangeLogUrgency urgency) {
153 		this.urgency = urgency;
154 	}
155 
156 
157 	@Override
158 	public List<ChangeLogVersionEntryDetail> getDetails() {
159 		return (new ArrayList<>(this.details));
160 	}
161 
162 
163 	/**
164 	 * <p>
165 	 * Sets the details.
166 	 * </p>
167 	 *
168 	 * @param details
169 	 *            The details.
170 	 */
171 	public void setDetails(List<ChangeLogVersionEntryDetail> details) {
172 		if (details == null) {
173 			this.details = new ArrayList<>();
174 		} else {
175 			this.details = new ArrayList<>(details);
176 		}
177 	}
178 
179 
180 	/**
181 	 * <p>
182 	 * Adds a detail.
183 	 * </p>
184 	 * 
185 	 * @param detail
186 	 *            The detail.
187 	 * @throws IllegalArgumentException
188 	 *             If the detail is <code>null</code>.
189 	 */
190 	public void addDetail(ChangeLogVersionEntryDetail detail) {
191 		if (detail == null)
192 			throw new IllegalArgumentException("Argument detail is null.");
193 		
194 		this.details.add(detail);
195 	}
196 
197 
198 	@Override
199 	public PackageMaintainer getMaintainer() {
200 		return this.maintainer;
201 	}
202 	
203 	
204 	/**
205 	 * <p>
206 	 * Sets the maintainer.
207 	 * </p>
208 	 *
209 	 * @param maintainer
210 	 *            The maintainer.
211 	 */
212 	public void setMaintainer(PackageMaintainer maintainer) {
213 		this.maintainer = maintainer;
214 	}
215 
216 
217 	@Override
218 	public Date getDate() {
219 		return this.date;
220 	}
221 	
222 	
223 	/**
224 	 * <p>
225 	 * Sets the date,
226 	 * </p>
227 	 *
228 	 * @param date
229 	 *            The date.
230 	 */
231 	public void setDate(Date date) {
232 		this.date = date;
233 	}
234 
235 
236 }