Record Class Range

java.lang.Object
java.lang.Record
com.github.tonivade.purefun.data.Range
All Implemented Interfaces:
Iterable<Integer>

public record Range(int begin, int end, int increment) extends Record implements Iterable<Integer>
  • Field Details

    • begin

      private final int begin
      The field for the begin record component.
    • end

      private final int end
      The field for the end record component.
    • increment

      private final int increment
      The field for the increment record component.
  • Constructor Details

    • Range

      public Range(int begin, int end)
    • Range

      public Range(int begin, int end, int increment)
      Creates an instance of a Range record class.
      Parameters:
      begin - the value for the begin record component
      end - the value for the end record component
      increment - the value for the increment record component
  • Method Details

    • reverse

      public Range reverse()
    • contains

      public boolean contains(int value)
    • size

      public int size()
    • collect

      public ImmutableArray<Integer> collect()
    • map

      public <T> ImmutableArray<T> map(Function1<? super Integer,? extends T> map)
    • intStream

      public IntStream intStream()
    • stream

      public Stream<Integer> stream()
    • iterator

      public Iterator<Integer> iterator()
      Specified by:
      iterator in interface Iterable<Integer>
    • 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
    • of

      public static Range of(int begin, int end)
    • of

      public static Range of(int begin, int end, int increment)
    • 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 '=='.
      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.
    • begin

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

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

      public int increment()
      Returns the value of the increment record component.
      Returns:
      the value of the increment record component