Class Version
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.Version
-
- All Implemented Interfaces:
Comparable<Version>
public class Version extends Object implements Comparable<Version>
Implements a package version.- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(Version o)Compares this version to the given one.static @NotNull Versioncreate(@Nullable String str)Creates a new version from the given string.static @NotNull Versioncreate(@Nullable String[] segments)Creates a new version from version segmentsbooleanequals(Object o)String[]getNormalizedSegments()Returns all segments.inthashCode()booleanisSnapshot()intosgiCompareTo(Version o)Deprecated.since 3.1.32. usecompareTo(Version).StringtoString()
-
-
-
Field Detail
-
EMPTY
public static final Version EMPTY
The empty version
-
-
Method Detail
-
create
@NotNull public static @NotNull Version create(@Nullable @Nullable String str)
Creates a new version from the given string.- Parameters:
str- the version string.- Returns:
- the new version or
EMPTYifstris an empty string. - Since:
- 2.2.4
-
create
@NotNull public static @NotNull Version create(@Nullable @Nullable String[] segments)
Creates a new version from version segments- Parameters:
segments- version segments- Returns:
- the new version or
EMPTYifsegmentsis empty. - Since:
- 2.2.4
-
getNormalizedSegments
public String[] getNormalizedSegments()
Returns all segments.- Returns:
- all segments.
-
compareTo
public int compareTo(Version o)
Compares this version to the given one. The comparison complies with the ordering used by Apache Maven. A version usually consists out of three numerical parts separated by dot - major version, minor version and patch level, and can be followed by a dash and a qualifier like SNAPSHOT. Version numbers can also consist of fewer or more parts (numerical, string, ....).Some examples: "1" < "2" "1.0" < "2" "2.0.1" < "2.1" "2.1" < "2.1.1" "2.9" < "2.11" "2.1-SNAPSHOT" < "2.1" "2.1-RC1" < "2.1" "2.1-RC1" < "2.1-SNAPSHOT"
Please note that this comparison does not use the exact segmentation presented ingetNormalizedSegments(), but applies the maven comparison algorithm to the string representationtoString().- Specified by:
compareToin interfaceComparable<Version>- Parameters:
o- the other version, not null- Returns:
- a negative integer, zero, or a positive integer as this version is less than, equal to, or greater than the specified version.
- See Also:
- Maven version order specification, Semantic Versioning 1.0.0
-
osgiCompareTo
@Deprecated public int osgiCompareTo(Version o)
Deprecated.since 3.1.32. usecompareTo(Version). See JCRVLT-146Same as withcompareTo(Version).- Parameters:
o- the other version- Returns:
- a negative integer, zero, or a positive integer as this version is less than, equal to, or greater than the specified version.
-
isSnapshot
public boolean isSnapshot()
- Returns:
truein case this version indicates a SNAPSHOT (i.e. mutable) version- Since:
- 3.7.0
-
-