Class RangeHalfOpenI

  • All Implemented Interfaces:
    RangeHalfOpenIType

    public final class RangeHalfOpenI
    extends java.lang.Object
    implements RangeHalfOpenIType
    A half open (inclusive lower, exclusive upper) range with int components.
    Since:
    4.0.0
    • Method Detail

      • lower

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

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

        public final RangeHalfOpenI 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 RangeHalfOpenI 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​(java.lang.Object another)
        This instance is equal to all instances of RangeHalfOpenI that have equal attribute values.
        Overrides:
        equals in class java.lang.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 java.lang.Object
        Returns:
        hashCode value
      • toString

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

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

        public static RangeHalfOpenI copyOf​(RangeHalfOpenIType instance)
        Creates an immutable copy of a RangeHalfOpenIType 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 RangeHalfOpenI instance
      • builder

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