Package ca.solostudios.strata.version
Class VersionRange
- java.lang.Object
-
- ca.solostudios.strata.version.VersionRange
-
- All Implemented Interfaces:
Formattable
public final class VersionRange extends java.lang.Object implements Formattable
A class representing a range of versions.
-
-
Constructor Summary
Constructors Constructor Description VersionRange(@Nullable Version startVersion, boolean startInclusive, @Nullable Version endVersion, boolean endInclusive)Constructs a new version range.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)@Nullable VersiongetEndVersion()The upper bound for the version range.@NotNull java.lang.StringgetFormatted()This object represented as a short and human readable string.@Nullable VersiongetStartVersion()The lower bound for the version range.inthashCode()booleanisEndInclusive()Wehther or not the upper version is inclusive.booleanisSatisfiedBy(Version version)Whether or not this range is satisfied by the provided version.booleanisSatisfiedBy(java.lang.String version)Whether or not this range is satisfied by the provided version.booleanisStartInclusive()Whether or not the lower version is inclusive.java.lang.StringtoString()
-
-
-
Constructor Detail
-
VersionRange
public VersionRange(@Nullable @Nullable Version startVersion, boolean startInclusive, @Nullable @Nullable Version endVersion, boolean endInclusive)Constructs a new version range.- Parameters:
startVersion- The starting version. Usenullif this has no lower bound.startInclusive-trueif the starting version is inclusive,falseif the starting version is exclusive.endVersion- The ending version. Usenullif this has no upper bound.endInclusive-trueif the ending version is inclusive,falseif the ending version is exclusive.
-
-
Method Detail
-
getStartVersion
@Nullable public @Nullable Version getStartVersion()
The lower bound for the version range.nullis returned if this has no lower bound.- Returns:
- The start version.
- See Also:
isStartInclusive()
-
isStartInclusive
public boolean isStartInclusive()
Whether or not the lower version is inclusive.- Returns:
trueif the start is inclusive,falseif the start is exclusive.- See Also:
getStartVersion()
-
getEndVersion
@Nullable public @Nullable Version getEndVersion()
The upper bound for the version range.nullis used if this has no upper bound.- Returns:
- The end version.
- See Also:
isEndInclusive()
-
isEndInclusive
public boolean isEndInclusive()
Wehther or not the upper version is inclusive.- Returns:
trueif the end is inclusive,falseif the end is exclusive.- See Also:
getEndVersion()
-
isSatisfiedBy
public boolean isSatisfiedBy(java.lang.String version) throws ParseExceptionWhether or not this range is satisfied by the provided version.- Parameters:
version- The version to check against.- Returns:
trueif this range is satisfied by the provided version,falseotherwise.- Throws:
ParseException- If an exception occurred during the parsing of the version. If taking user input, the message from this exception is highly useful and should be returned to the user.@see Versions#parseVersion(String)- See Also:
Versions.parseVersion(String)
-
isSatisfiedBy
public boolean isSatisfiedBy(Version version)
Whether or not this range is satisfied by the provided version.- Parameters:
version- The version to check against.- Returns:
trueif this range is satisfied by the provided version,falseotherwise.
-
toString
@Contract(pure=true) public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getFormatted
@NotNull public @NotNull java.lang.String getFormatted()
Description copied from interface:FormattableThis object represented as a short and human readable string.- Specified by:
getFormattedin interfaceFormattable- Returns:
- This object as a readable string.
-
-