Class VersionRange
- Version:
- $Id: VersionRange.java 640549 2008-03-24 20:05:11Z bentmann $
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
VersionRange
(ArtifactVersion recommendedVersion, List restrictions) -
Method Summary
Modifier and TypeMethodDescriptioncloneOf()
boolean
containsVersion
(ArtifactVersion version) static VersionRange
createFromVersion
(String version) static VersionRange
createFromVersionSpec
(String spec) Create a version range from a string representation Some spec examples are1.0
Version 1.0[1.0,2.0)
Versions 1.0 (included) to 2.0 (not included)[1.0,2.0]
Versions 1.0 to 2.0 (both included)[1.5,)
Versions 1.5 and higher(,1.0],[1.2,)
Versions up to 1.0 (included) and 1.2 or higherboolean
getSelectedVersion
(Artifact artifact) int
hashCode()
boolean
private List
intersection
(List r1, List r2) boolean
isSelectedVersionKnown
(Artifact artifact) matchVersion
(List versions) private static Restriction
parseRestriction
(String spec) restrict
(VersionRange restriction) Creates and returns a newVersionRange
that is a restriction of this version range and the specified version range.toString()
-
Field Details
-
recommendedVersion
-
restrictions
-
-
Constructor Details
-
VersionRange
-
-
Method Details
-
getRecommendedVersion
-
getRestrictions
-
cloneOf
-
createFromVersionSpec
public static VersionRange createFromVersionSpec(String spec) throws InvalidVersionSpecificationException Create a version range from a string representation Some spec examples are1.0
Version 1.0[1.0,2.0)
Versions 1.0 (included) to 2.0 (not included)[1.0,2.0]
Versions 1.0 to 2.0 (both included)[1.5,)
Versions 1.5 and higher(,1.0],[1.2,)
Versions up to 1.0 (included) and 1.2 or higher
- Parameters:
spec
- string representation of a version or version range- Returns:
- a new
VersionRange
object that represents the spec - Throws:
InvalidVersionSpecificationException
-
parseRestriction
private static Restriction parseRestriction(String spec) throws InvalidVersionSpecificationException -
createFromVersion
-
restrict
Creates and returns a newVersionRange
that is a restriction of this version range and the specified version range.Note: Precedence is given to the recommended version from this version range over the recommended version from the specified version range.
- Parameters:
restriction
- theVersionRange
that will be used to restrict this version range.- Returns:
- the
VersionRange
that is a restriction of this version range and the specified version range.The restrictions of the returned version range will be an intersection of the restrictions of this version range and the specified version range if both version ranges have restrictions. Otherwise, the restrictions on the returned range will be empty.
The recommended version of the returned version range will be the recommended version of this version range, provided that ranges falls within the intersected restrictions. If the restrictions are empty, this version range's recommended version is used if it is not
null
. If it isnull
, the specified version range's recommended version is used (provided it is non-null
). If no recommended version can be obtained, the returned version range's recommended version is set tonull
. - Throws:
NullPointerException
- if the specifiedVersionRange
isnull
.
-
intersection
-
getSelectedVersion
- Throws:
OverConstrainedVersionException
-
isSelectedVersionKnown
- Throws:
OverConstrainedVersionException
-
toString
-
matchVersion
-
containsVersion
-
hasRestrictions
public boolean hasRestrictions() -
equals
-
hashCode
public int hashCode()
-