Package dev.gigaherz.versible
Record Class VersibleRange
java.lang.Object
java.lang.Record
dev.gigaherz.versible.VersibleRange
- Record Components:
minVersion- The lower bound of the interval. Can benull.minExclusive- If theminVersionparam is notnull, determines whether the lower bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.maxVersion- The upper bound of the interval. Can benull.maxExclusive- If themaxVersionparam is notnull, determines whether the upper bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.
- All Implemented Interfaces:
Predicate<VersibleVersion>
public record VersibleRange(@Nullable VersibleVersion minVersion, boolean minExclusive, @Nullable VersibleVersion maxVersion, boolean maxExclusive)
extends Record
implements Predicate<VersibleVersion>
Represents a version range.
-
Constructor Summary
ConstructorsConstructorDescriptionVersibleRange(@Nullable VersibleVersion minVersion, boolean minExclusive, @Nullable VersibleVersion maxVersion, boolean maxExclusive) Constructs a version range. -
Method Summary
Modifier and TypeMethodDescriptionstatic VersibleRangeatLeast(VersibleVersion min) Returns a version range which matches versions greater or equal to the given minimum.static VersibleRangeatMost(VersibleVersion max) Returns a version range which matches versions less or equal to the given maximum.static VersibleRangebetween(VersibleVersion min, VersibleVersion max) Returns a version range which matches versions between the given minimum (inclusive) and maximum (inclusive).static VersibleRangebetweenClosedOpen(VersibleVersion min, VersibleVersion max) Returns a version range which matches versions between the given minimum (inclusive) and maximum (exclusive).static VersibleRangebetweenOpen(VersibleVersion min, VersibleVersion max) Returns a version range which matches versions between the given minimum (exclusive) and maximum (exclusive).static VersibleRangebetweenOpenClosed(VersibleVersion min, VersibleVersion max) Returns a version range which matches versions between the given minimum (exclusive) and maximum (inclusive).booleancontains(VersibleVersion version) Checks if a given version is included in the range.booleanIndicates whether some other object is "equal to" this one.static VersibleRangeexactly(VersibleVersion version) Returns a version range which matches a given version exactly.inthashCode()Returns a hash code value for this object.static VersibleRangelessThan(VersibleVersion max) Returns a version range which matches versions strictly less than the given maximum.booleanReturns the value of themaxExclusiverecord component.@Nullable VersibleVersionReturns the value of themaxVersionrecord component.booleanReturns the value of theminExclusiverecord component.@Nullable VersibleVersionReturns the value of theminVersionrecord component.static VersibleRangemoreThan(VersibleVersion min) Returns a version range which matches versions strictly greater than the given minimum.booleantest(VersibleVersion version) toString()Returns a string representation of this record class.
-
Constructor Details
-
VersibleRange
@Contract("null, _, null, _ -> fail") @Internal public VersibleRange(@Nullable @Nullable VersibleVersion minVersion, boolean minExclusive, @Nullable @Nullable VersibleVersion maxVersion, boolean maxExclusive) Constructs a version range.- Parameters:
minVersion- The lower bound of the interval. Can benull.minExclusive- If theminVersionparam is notnull, determines whether the lower bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.maxVersion- The upper bound of the interval. Can benull.maxExclusive- If themaxVersionparam is notnull, determines whether the upper bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.- Throws:
IllegalArgumentException- IfminVersionandmaxVersionare bothnullat the same time.
-
-
Method Details
-
between
Returns a version range which matches versions between the given minimum (inclusive) and maximum (inclusive).- Parameters:
min- The lower bound (inclusive).max- The upperbound (inclusive).- Returns:
- A version range.
-
betweenOpen
Returns a version range which matches versions between the given minimum (exclusive) and maximum (exclusive).- Parameters:
min- The lower bound (exclusive).max- The upperbound (exclusive).- Returns:
- A version range.
-
betweenClosedOpen
Returns a version range which matches versions between the given minimum (inclusive) and maximum (exclusive).- Parameters:
min- The lower bound (inclusive).max- The upperbound (exclusive).- Returns:
- A version range.
-
betweenOpenClosed
Returns a version range which matches versions between the given minimum (exclusive) and maximum (inclusive).- Parameters:
min- The lower bound (exclusive).max- The upperbound (inclusive).- Returns:
- A version range.
-
atLeast
Returns a version range which matches versions greater or equal to the given minimum.- Parameters:
min- The version to compare against.- Returns:
- A version range.
-
moreThan
Returns a version range which matches versions strictly greater than the given minimum.- Parameters:
min- The version to compare against.- Returns:
- A version range.
-
atMost
Returns a version range which matches versions less or equal to the given maximum.- Parameters:
max- The version to compare against.- Returns:
- A version range.
-
lessThan
Returns a version range which matches versions strictly less than the given maximum.- Parameters:
max- The version to compare against.- Returns:
- A version range.
-
exactly
Returns a version range which matches a given version exactly.- Parameters:
version- The version to match.- Returns:
- A version range.
-
contains
Checks if a given version is included in the range.- Parameters:
version- The version to check.- Returns:
trueif the version is included,falseothersie.
-
test
- Specified by:
testin interfacePredicate<VersibleVersion>
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
minVersion
Returns the value of theminVersionrecord component.- Returns:
- the value of the
minVersionrecord component
-
minExclusive
public boolean minExclusive()Returns the value of theminExclusiverecord component.- Returns:
- the value of the
minExclusiverecord component
-
maxVersion
Returns the value of themaxVersionrecord component.- Returns:
- the value of the
maxVersionrecord component
-
maxExclusive
public boolean maxExclusive()Returns the value of themaxExclusiverecord component.- Returns:
- the value of the
maxExclusiverecord component
-