Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
VersionConstraint | 34 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software 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 GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.extension.version; | |
21 | ||
22 | import java.io.Serializable; | |
23 | import java.util.Collection; | |
24 | ||
25 | /** | |
26 | * An extension version constraint. Generally on a dependency. A constraint can either consist of one or more version | |
27 | * ranges or a single version. In the first case, the constraint expresses a hard requirement on a version matching one | |
28 | * of its ranges. In the second case, the constraint expresses a soft requirement on a specific version (i.e. a | |
29 | * recommendation). | |
30 | * | |
31 | * @version $Id: 29e8f72fccc7085bbff0c0a3824427be95769326 $ | |
32 | * @since 4.0M1 | |
33 | */ | |
34 | public interface VersionConstraint extends Serializable | |
35 | { | |
36 | /** | |
37 | * Gets the version ranges of this constraint. | |
38 | * | |
39 | * @return the version ranges, never null. | |
40 | */ | |
41 | Collection<VersionRangeCollection> getRanges(); | |
42 | ||
43 | /** | |
44 | * Gets the version recommended by this constraint. | |
45 | * | |
46 | * @return the recommended version or null if none. | |
47 | */ | |
48 | Version getVersion(); | |
49 | ||
50 | /** | |
51 | * @return a String representation of the version constraint | |
52 | */ | |
53 | String getValue(); | |
54 | ||
55 | /** | |
56 | * Indicate if the provided {@link Version} satisfies the constraint. | |
57 | * | |
58 | * @param version the version to test, null is invalid | |
59 | * @return true if the provided version satisfies this constraint, false otherwise | |
60 | */ | |
61 | boolean containsVersion(Version version); | |
62 | ||
63 | /** | |
64 | * Indicate of the provided {@link Version} is compatible with this version. | |
65 | * <p> | |
66 | * The difference with {@link #containsVersion(Version)} is that this method is trying to determine if this version | |
67 | * should work with this constraint while {@link #containsVersion(Version)} indicate if that's the ideal version for | |
68 | * this constraint. This apply with constraint not defining an exact version range but only a recommended version | |
69 | * constraint, in that case the constraint indicate what is the version that would ideally be required but it should | |
70 | * work with more recent version. | |
71 | * | |
72 | * @param version the version to test, null is invalid | |
73 | * @return true if the provided version is compatible with this constraint | |
74 | * @since 4.1M2 | |
75 | */ | |
76 | boolean isCompatible(Version version); | |
77 | ||
78 | /** | |
79 | * Merge two versions constraints in one. | |
80 | * | |
81 | * @param versionConstraint the version constraint to merge with this version constraint | |
82 | * @return the merged version constraint | |
83 | * @throws IncompatibleVersionConstraintException the provided version constraint is not compatible with the | |
84 | * provided version constraint | |
85 | */ | |
86 | VersionConstraint merge(VersionConstraint versionConstraint) throws IncompatibleVersionConstraintException; | |
87 | } |