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 boolean
equals(java.lang.Object o)
@Nullable Version
getEndVersion()
The upper bound for the version range.@NotNull java.lang.String
getFormatted()
This object represented as a short and human readable string.@Nullable Version
getStartVersion()
The lower bound for the version range.int
hashCode()
boolean
isEndInclusive()
Wehther or not the upper version is inclusive.boolean
isSatisfiedBy(Version version)
Whether or not this range is satisfied by the provided version.boolean
isSatisfiedBy(java.lang.String version)
Whether or not this range is satisfied by the provided version.boolean
isStartInclusive()
Whether or not the lower version is inclusive.java.lang.String
toString()
-
-
-
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. Usenull
if this has no lower bound.startInclusive
-true
if the starting version is inclusive,false
if the starting version is exclusive.endVersion
- The ending version. Usenull
if this has no upper bound.endInclusive
-true
if the ending version is inclusive,false
if the ending version is exclusive.
-
-
Method Detail
-
getStartVersion
@Nullable public @Nullable Version getStartVersion()
The lower bound for the version range.null
is 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:
true
if the start is inclusive,false
if the start is exclusive.- See Also:
getStartVersion()
-
getEndVersion
@Nullable public @Nullable Version getEndVersion()
The upper bound for the version range.null
is 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:
true
if the end is inclusive,false
if the end is exclusive.- See Also:
getEndVersion()
-
isSatisfiedBy
public boolean isSatisfiedBy(java.lang.String version) throws ParseException
Whether or not this range is satisfied by the provided version.- Parameters:
version
- The version to check against.- Returns:
true
if this range is satisfied by the provided version,false
otherwise.- 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:
true
if this range is satisfied by the provided version,false
otherwise.
-
toString
@Contract(pure=true) public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getFormatted
@NotNull public @NotNull java.lang.String getFormatted()
Description copied from interface:Formattable
This object represented as a short and human readable string.- Specified by:
getFormatted
in interfaceFormattable
- Returns:
- This object as a readable string.
-
-