Record Class VersibleRange

java.lang.Object
java.lang.Record
dev.gigaherz.versible.VersibleRange
Record Components:
minVersion - The lower bound of the interval. Can be null.
minExclusive - If the minVersion param is not null, determines whether the lower bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.
maxVersion - The upper bound of the interval. Can be null.
maxExclusive - If the maxVersion param is not null, 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 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 be null.
      minExclusive - If the minVersion param is not null, determines whether the lower bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.
      maxVersion - The upper bound of the interval. Can be null.
      maxExclusive - If the maxVersion param is not null, determines whether the upper bound is inclusive (false) or exclusive (true). Otherwise, this parameter is ignored.
      Throws:
      IllegalArgumentException - If minVersion and maxVersion are both null at the same time.
  • Method Details

    • between

      public static VersibleRange between(VersibleVersion min, VersibleVersion max)
      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

      public static VersibleRange betweenOpen(VersibleVersion min, VersibleVersion max)
      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

      public static VersibleRange betweenClosedOpen(VersibleVersion min, VersibleVersion max)
      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

      public static VersibleRange betweenOpenClosed(VersibleVersion min, VersibleVersion max)
      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

      public static VersibleRange atLeast(VersibleVersion min)
      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

      public static VersibleRange moreThan(VersibleVersion min)
      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

      public static VersibleRange atMost(VersibleVersion max)
      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

      public static VersibleRange lessThan(VersibleVersion max)
      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

      public static VersibleRange exactly(VersibleVersion version)
      Returns a version range which matches a given version exactly.
      Parameters:
      version - The version to match.
      Returns:
      A version range.
    • contains

      public boolean contains(VersibleVersion version)
      Checks if a given version is included in the range.
      Parameters:
      version - The version to check.
      Returns:
      true if the version is included, false othersie.
    • test

      public boolean test(VersibleVersion version)
      Specified by:
      test in interface Predicate<VersibleVersion>
    • equals

      public boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • minVersion

      @Nullable public @Nullable VersibleVersion minVersion()
      Returns the value of the minVersion record component.
      Returns:
      the value of the minVersion record component
    • minExclusive

      public boolean minExclusive()
      Returns the value of the minExclusive record component.
      Returns:
      the value of the minExclusive record component
    • maxVersion

      @Nullable public @Nullable VersibleVersion maxVersion()
      Returns the value of the maxVersion record component.
      Returns:
      the value of the maxVersion record component
    • maxExclusive

      public boolean maxExclusive()
      Returns the value of the maxExclusive record component.
      Returns:
      the value of the maxExclusive record component