Record Class Multirange<A>

java.lang.Object
java.lang.Record
io.codemine.java.postgresql.codecs.Multirange<A>
Type Parameters:
A - the element type of the ranges
Record Components:
ranges - the list of ranges in this multirange, in sorted order

public record Multirange<A>(List<Range<A>> ranges) extends Record
PostgreSQL multirange type. A collection of non-overlapping, non-adjacent ranges stored as a single value.

PostgreSQL automatically normalizes multiranges by combining overlapping and adjacent ranges. The ranges are stored in sorted order.

The standard PostgreSQL multirange types are:

  • int4multirangeMultirange<Integer>
  • int8multirangeMultirange<Long>
  • nummultirangeMultirange<java.math.BigDecimal>
  • tsmultirangeMultirange<java.time.LocalDateTime>
  • tstzmultirangeMultirange<java.time.Instant>
  • datemultirangeMultirange<java.time.LocalDate>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Multirange(List<Range<A>> ranges)
    Compact constructor that makes an immutable copy of ranges.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the ranges record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • Multirange

      public Multirange(List<Range<A>> ranges)
      Compact constructor that makes an immutable copy of ranges.
  • Method Details

    • 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
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • ranges

      public List<Range<A>> ranges()
      Returns the value of the ranges record component.
      Returns:
      the value of the ranges record component