Record Class VersionRange

java.lang.Object
java.lang.Record
fr.robie.machineengine.api.version.VersionRange

public record VersionRange(@Nullable Version lower, boolean lowerInclusive, @Nullable Version upper, boolean upperInclusive) extends Record
A Maven-style version range: [1.0,2.0), (,1.5], [2.0,), [1.2] (exactly 1.2), or a bare version 1.2, which means "1.2 or newer".

Ranges compare base versions: qualifiers are ignored.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final VersionRange
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    VersionRange(@Nullable Version lower, boolean lowerInclusive, @Nullable Version upper, boolean upperInclusive)
    Creates an instance of a VersionRange record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(@NotNull Version version)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @Nullable Version
    Returns the value of the lower record component.
    boolean
    Returns the value of the lowerInclusive record component.
    static @NotNull VersionRange
    parse(@NotNull String text)
     
    @NotNull String
    Returns a string representation of this record class.
    @Nullable Version
    Returns the value of the upper record component.
    boolean
    Returns the value of the upperInclusive record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • VersionRange

      public VersionRange(@Nullable @Nullable Version lower, boolean lowerInclusive, @Nullable @Nullable Version upper, boolean upperInclusive)
      Creates an instance of a VersionRange record class.
      Parameters:
      lower - the value for the lower record component
      lowerInclusive - the value for the lowerInclusive record component
      upper - the value for the upper record component
      upperInclusive - the value for the upperInclusive record component
  • Method Details

    • parse

      @NotNull public static @NotNull VersionRange parse(@NotNull @NotNull String text)
      Throws:
      IllegalArgumentException - if text is not a range
    • contains

      public boolean contains(@NotNull @NotNull Version version)
    • toString

      @NotNull public @NotNull 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
    • hashCode

      public final 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
    • equals

      public final 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 the compare method from their corresponding wrapper classes.
      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.
    • lower

      @Nullable public @Nullable Version lower()
      Returns the value of the lower record component.
      Returns:
      the value of the lower record component
    • lowerInclusive

      public boolean lowerInclusive()
      Returns the value of the lowerInclusive record component.
      Returns:
      the value of the lowerInclusive record component
    • upper

      @Nullable public @Nullable Version upper()
      Returns the value of the upper record component.
      Returns:
      the value of the upper record component
    • upperInclusive

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