Interface Version<T extends Version<T>>
- Type Parameters:
T- The version type (denotes which types this version can be compared with).
- All Superinterfaces:
Comparable<T>
- All Known Implementing Classes:
SemanticVersion
-
Method Summary
Modifier and TypeMethodDescriptionintCompares this version with the specified version.booleanIndicates whether the other version object is equal to this one.default booleanisEquivalent(@NonNull T other) A convenience method that invokescompareTo(T)and checks whether the result is equal to zero.default booleanisGreaterThan(@NonNull T other) A convenience method that invokescompareTo(T)and checks whether the result is greater than zero.default booleanisLessThan(@NonNull T other) A convenience method that invokescompareTo(T)and checks whether the result is less than zero.@NonNull StringtoString()Renders the version as either its original string, or a new equivalent string.
-
Method Details
-
compareTo
Compares this version with the specified version.The comparison adheres to the
Comparablespecification and semantics.- Specified by:
compareToin interfaceComparable<T extends Version<T>>- Parameters:
other- the object to be compared.- Returns:
- a negative integer if this version is less than the other version, zero if the versions are equal or a positive integer if this version is greater than the other version.
- Throws:
NullPointerException- If the other version is null.
-
isLessThan
A convenience method that invokescompareTo(T)and checks whether the result is less than zero.- Parameters:
other- The other version.- Returns:
- True if, and only if, the other version is less than this version.
-
isEquivalent
A convenience method that invokescompareTo(T)and checks whether the result is equal to zero.This is NOT necessarily the same as
equals(Object). This method follows the semantics of the version specification rather than of Java objects (for the latter, useequals(Object)). The implementation notes of the concrete version type should provide more specific details.- Parameters:
other- The other version.- Returns:
- True if, and only if, the other version is considered equivalent per the version's specification.
- See Also:
-
isGreaterThan
A convenience method that invokescompareTo(T)and checks whether the result is greater than zero.- Parameters:
other- The other version.- Returns:
- True if, and only if, the other version is greater than this version.
-
equals
Indicates whether the other version object is equal to this one.This follows the semantics of
Object.equals(Object)and is intended for comparing version object values (the representation rather than the semantics) with each other.This method does not necessarily follow the ordering or semantics of equality of the version specification. For that use case, instead use
isEquivalent(Version).For example, Semantic Versioning (SemVer) stipulates that build metadata not be considered in precedence, but it is still part of the version string, so for versions that differ only by build metadata,
equalswould return false andisEquivalent(Version)would return true. -
toString
-