Class PrefixedVersion
java.lang.Object
io.github.bakedlibs.dough.versions.PrefixedVersion
- All Implemented Interfaces:
Version,Comparable<Version>
This
Version implementation consists of two components.
A prefix, e.g. "DEV #" or "pre-" and a numeric version component.
Only PrefixedVersions with the same prefix can be compared.- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorsConstructorDescriptionPrefixedVersion(String prefix, int version) This constructs a newPrefixedVersionwith the given prefix and version number. -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis method returns thisVersionas a human-readable format.final StringThis returns the prefix for thisPrefixedVersion.final intThis method returns the version number which this numericVersionrepresents.inthashCode()booleanbooleanisNewerThan(Version version) booleanisOlderThan(Version version) booleantoString()
-
Constructor Details
-
PrefixedVersion
This constructs a newPrefixedVersionwith the given prefix and version number. The version number cannot be negative.- Parameters:
prefix- The prefixversion- The version number
-
-
Method Details
-
isSimilar
This returns whether thisVersionis "similar" to the givenVersion. TwoVersions are considered "similar" when they can be compared to each other without causing anIncomparableVersionsException. -
getAsString
This method returns thisVersionas a human-readable format. Example:1.4.2. -
getPrefix
This returns the prefix for thisPrefixedVersion.- Returns:
- The prefix
-
hashCode
public int hashCode() -
equals
-
toString
-
getVersionNumber
public final int getVersionNumber()This method returns the version number which this numericVersionrepresents.- Returns:
- The version number
-
isNewerThan
This method returns whether thisVersionis newer than the providedVersion. This also implies that the providedVersionis older than thisVersion, seeVersion.isOlderThan(Version).This method may throw an
IncomparableVersionsExceptionif the two versions cannot be compared with each other.- Specified by:
isNewerThanin interfaceVersion- Parameters:
version- TheVersionto compare this to- Returns:
- Whether this
Versionis newer than the provided one.
-
isEqualTo
This method returns whether thisVersionis equal to the givenVersion.This method may throw an
IncomparableVersionsExceptionif the two versions cannot be compared with each other. -
isOlderThan
This method returns whether thisVersionis older than the providedVersion. This also implies that the providedVersionis newer than thisVersion, seeVersion.isNewerThan(Version).This method may throw an
IncomparableVersionsExceptionif the two versions cannot be compared with each other.- Specified by:
isOlderThanin interfaceVersion- Parameters:
version- TheVersionto compare this to- Returns:
- Whether this
Versionis older than the provided one.
-