Record Class CollectionsP.Replacement<T>

java.lang.Object
java.lang.Record
org.plumelib.util.CollectionsP.Replacement<T>
Type Parameters:
T - the type of collection elements
Record Components:
start - the first index to replace, inclusive; must be non-negative
end - the last index to replace, inclusive; may be start-1 to indicate an empty range (an insertion)
elements - the new (replacement) elements
Enclosing class:
CollectionsP

public static record CollectionsP.Replacement<T>(int start, int end, Collection<T> elements) extends Record
Represents a replacement of one range of a collection by another collection.
  • Constructor Details

    • Replacement

      public Replacement(int start, int end, Collection<T> elements)
      Creates a new Replacement.
      Parameters:
      start - the first index to replace, inclusive; must be non-negative
      end - the last index to replace, inclusive; may be start-1 to indicate an empty range (an insertion)
      elements - the new (replacement) elements
  • Method Details

    • of

      public static <T> CollectionsP.Replacement<T> of(int start, int end, Collection<T> elements)
      Creates a new Replacement.
      Type Parameters:
      T - the type of elements of the list
      Parameters:
      start - the first index to replace, inclusive; must be non-negative
      end - the last index to replace, inclusive; may be start-1 to indicate an empty range (an insertion)
      elements - the new (replacement) elements
      Returns:
      a new Replacement
    • toString

      public String toString(@GuardSatisfied CollectionsP.Replacement<T> this)
      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 '=='.
      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.
    • start

      public int start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • end

      public int end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component
    • elements

      public Collection<T> elements()
      Returns the value of the elements record component.
      Returns:
      the value of the elements record component