Record Class Entry

java.lang.Object
java.lang.Record
com.nerjal.ip_range_parser.Entry
Record Components:
name - The name or identifier associated with the entry.
ranges - A sorted set of Pair objects defining the range(s) for the entry.

public record Entry(String name, SortedSet<Pair> ranges) extends Record
Represents an entry containing a name and a sorted set of range pairs.

An Entry object serves as a container for a string identifier (name) and a collection of ranges represented as Pair instances. The ranges are stored in a sorted set, ensuring they remain ordered according to their natural ordering as defined in the Pair record.

Each Pair comprises two BigInteger values, representing the bounds of a range, and is comparable based on its first value (Pair.i1()).

This record provides an immutable and thread-safe way of managing entries and their associated ranges.

  • Constructor Details

    • Entry

      public Entry(String name, SortedSet<Pair> ranges)
      Creates an instance of a Entry record class.
      Parameters:
      name - the value for the name record component
      ranges - the value for the ranges record component
  • Method Details

    • toString

      public final 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • ranges

      public SortedSet<Pair> ranges()
      Returns the value of the ranges record component.
      Returns:
      the value of the ranges record component