Class ProtocolVersionRange
java.lang.Object
com.viaversion.viaversion.api.protocol.version.ProtocolVersionRange
Wrapper class file for
Range to support multiple ranges. This class is used to
compare ProtocolVersion objects.-
Method Summary
Modifier and TypeMethodDescriptionadd(com.google.common.collect.Range<ProtocolVersion> range) Adds a new range to this range.add(ProtocolVersionRange range) Adds all ranges from the given range to this range.static ProtocolVersionRangeall()Returns a range that contains all versions.static ProtocolVersionRangeandNewer(ProtocolVersion version) Returns a range that contains all versions equal to or newer than the given version.static ProtocolVersionRangeandOlder(ProtocolVersion version) Returns a range that contains all versions equal to or older than the given version.booleancontains(ProtocolVersion version) Checks if the given version is included in this range.booleanstatic ProtocolVersionRangefromString(String str) Parses a range from a string generated bytoString().@Nullable ProtocolVersiongetMax()Gets the maximum version in this range.@Nullable ProtocolVersiongetMin()Gets the minimum version in this range.inthashCode()static ProtocolVersionRangeof(com.google.common.collect.Range<ProtocolVersion> range) Returns a range that contains only the given version.static ProtocolVersionRangeof(ProtocolVersion min, ProtocolVersion max) Returns a range that contains only the given version.static ProtocolVersionRangeof(List<com.google.common.collect.Range<ProtocolVersion>> ranges) Returns a range that contains only the given version.static ProtocolVersionRangesingleton(ProtocolVersion version) Returns a range that contains only the given version.toString()
-
Method Details
-
all
Returns a range that contains all versions. Adding new ranges to this range is not supported.- Returns:
- the range
-
of
Returns a range that contains only the given version.- Parameters:
min- the versionmax- the version- Returns:
- the range
-
of
Returns a range that contains only the given version.- Parameters:
range- the version- Returns:
- the range
-
of
public static ProtocolVersionRange of(List<com.google.common.collect.Range<ProtocolVersion>> ranges) Returns a range that contains only the given version. The list can be immutable.- Parameters:
ranges- the version- Returns:
- the range
-
singleton
Returns a range that contains only the given version.- Parameters:
version- the version- Returns:
- the range
-
andNewer
Returns a range that contains all versions equal to or newer than the given version.- Parameters:
version- the version- Returns:
- the range
-
andOlder
Returns a range that contains all versions equal to or older than the given version.- Parameters:
version- the version- Returns:
- the range
-
add
Adds a new range to this range. This method is only available if the range is not already containing all versions.- Parameters:
range- the range to add- Returns:
- this range
-
add
Adds all ranges from the given range to this range. This method is only available if the range is not already containing all versions.- Parameters:
range- the range to add- Returns:
- this range
-
contains
Checks if the given version is included in this range.- Parameters:
version- the version- Returns:
trueif the version is included
-
getMin
Gets the minimum version in this range. If there are multiple ranges, the lowest minimum is returned.- Returns:
- the minimum version, or null if there is no minimum
-
getMax
Gets the maximum version in this range. If there are multiple ranges, the highest maximum is returned.- Returns:
- the maximum version, or null if there is no maximum
-
toString
-
equals
-
hashCode
public int hashCode() -
fromString
Parses a range from a string generated bytoString().- Parameters:
str- the string- Returns:
- the range
-