Package com.io7m.jranges
Class RangeInclusiveI
java.lang.Object
com.io7m.jranges.RangeInclusiveI
- All Implemented Interfaces:
RangeInclusiveIType
An inclusive range with
int
components.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RangeInclusiveI.Builder
builder()
Creates a builder forRangeInclusiveI
.static RangeInclusiveI
copyOf
(RangeInclusiveIType instance) Creates an immutable copy of aRangeInclusiveIType
value.boolean
This instance is equal to all instances ofRangeInclusiveI
that have equal attribute values.int
hashCode()
Computes a hash code from attributes:lower
,upper
.int
lower()
static RangeInclusiveI
of
(int lower, int upper) Construct a new immutableRangeInclusiveI
instance.toString()
Prints the immutable valueRangeInclusiveI
with attribute values.int
upper()
final RangeInclusiveI
withLower
(int value) Copy the current immutable object by setting a value for thelower
attribute.final RangeInclusiveI
withUpper
(int value) Copy the current immutable object by setting a value for theupper
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.io7m.jranges.RangeInclusiveIType
checkPreconditions, includesValue, interval, isIncludedIn
-
Method Details
-
lower
public int lower()- Specified by:
lower
in interfaceRangeInclusiveIType
- Returns:
- The lower bound of the inclusive range.
-
upper
public int upper()- Specified by:
upper
in interfaceRangeInclusiveIType
- Returns:
- The upper bound of the inclusive range.
-
withLower
Copy the current immutable object by setting a value for thelower
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for lower- Returns:
- A modified copy of the
this
object
-
withUpper
Copy the current immutable object by setting a value for theupper
attribute. A value equality check is used to prevent copying of the same value by returningthis
.- Parameters:
value
- A new value for upper- Returns:
- A modified copy of the
this
object
-
equals
This instance is equal to all instances ofRangeInclusiveI
that have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:lower
,upper
. -
toString
Prints the immutable valueRangeInclusiveI
with attribute values. -
of
Construct a new immutableRangeInclusiveI
instance.- Parameters:
lower
- The value for thelower
attributeupper
- The value for theupper
attribute- Returns:
- An immutable RangeInclusiveI instance
-
copyOf
Creates an immutable copy of aRangeInclusiveIType
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
Creates a builder forRangeInclusiveI
.RangeInclusiveI.builder() .setLower(int) // required
lower
.setUpper(int) // requiredupper
.build();- Returns:
- A new RangeInclusiveI builder
-