Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VersionsFile |
|
| 1.4;1.4 |
1 | package org.jtheque.core.managers.update.versions; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque 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 JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jtheque.utils.collections.CollectionUtils; | |
20 | ||
21 | import java.util.Collection; | |
22 | import java.util.List; | |
23 | import java.util.NoSuchElementException; | |
24 | ||
25 | /** | |
26 | * An online version's file. | |
27 | * | |
28 | * @author Baptiste Wicht | |
29 | */ | |
30 | 0 | public final class VersionsFile { |
31 | private List<OnlineVersion> onlineVersions; | |
32 | private InstallVersion installVersion; | |
33 | ||
34 | /** | |
35 | * Return all the versions contained in the file. | |
36 | * | |
37 | * @return A list containing all the versions of the file. | |
38 | */ | |
39 | public Collection<OnlineVersion> getVersions() { | |
40 | 0 | return onlineVersions; |
41 | } | |
42 | ||
43 | /** | |
44 | * Set the versions of the file. | |
45 | * | |
46 | * @param onlineVersions A list containing all the versions of the file. | |
47 | */ | |
48 | public void setVersions(Collection<OnlineVersion> onlineVersions) { | |
49 | 0 | this.onlineVersions = CollectionUtils.copyOf(onlineVersions); |
50 | 0 | } |
51 | ||
52 | /** | |
53 | * Return the install version of the file. | |
54 | * | |
55 | * @return The install version. | |
56 | */ | |
57 | public InstallVersion getInstallVersion() { | |
58 | 0 | return installVersion; |
59 | } | |
60 | ||
61 | /** | |
62 | * Set the install version. | |
63 | * | |
64 | * @param installVersion The install version. | |
65 | */ | |
66 | public void setInstallVersion(InstallVersion installVersion) { | |
67 | 0 | this.installVersion = installVersion; |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Return the most recent version of the VersionsFile. | |
72 | * | |
73 | * @return The most recent version. | |
74 | * @throws NoSuchElementException If the version's file contains no version. | |
75 | */ | |
76 | public OnlineVersion getMostRecentVersion() { | |
77 | 0 | if (onlineVersions.isEmpty()) { |
78 | 0 | throw new NoSuchElementException("The version's file contains no versions. "); |
79 | } | |
80 | ||
81 | 0 | return onlineVersions.get(onlineVersions.size() - 1); |
82 | } | |
83 | } |