Class RangeInclusiveI

java.lang.Object
com.io7m.jranges.RangeInclusiveI
All Implemented Interfaces:
RangeInclusiveIType

public final class RangeInclusiveI extends Object implements RangeInclusiveIType
An inclusive range with int components.
  • Method Details

    • lower

      public int lower()
      Specified by:
      lower in interface RangeInclusiveIType
      Returns:
      The lower bound of the inclusive range.
    • upper

      public int upper()
      Specified by:
      upper in interface RangeInclusiveIType
      Returns:
      The upper bound of the inclusive range.
    • withLower

      public final RangeInclusiveI withLower(int value)
      Copy the current immutable object by setting a value for the lower attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for lower
      Returns:
      A modified copy of the this object
    • withUpper

      public final RangeInclusiveI withUpper(int value)
      Copy the current immutable object by setting a value for the upper attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for upper
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of RangeInclusiveI that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: lower, upper.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value RangeInclusiveI with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • of

      public static RangeInclusiveI of(int lower, int upper)
      Construct a new immutable RangeInclusiveI instance.
      Parameters:
      lower - The value for the lower attribute
      upper - The value for the upper attribute
      Returns:
      An immutable RangeInclusiveI instance
    • copyOf

      public static RangeInclusiveI copyOf(RangeInclusiveIType instance)
      Creates an immutable copy of a RangeInclusiveIType value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable RangeInclusiveI instance
    • builder

      public static RangeInclusiveI.Builder builder()
      Creates a builder for RangeInclusiveI.
       RangeInclusiveI.builder()
          .setLower(int) // required lower
          .setUpper(int) // required upper
          .build();
       
      Returns:
      A new RangeInclusiveI builder