Package com.io7m.junsigned.ranges
Class UnsignedRangeInclusiveI
java.lang.Object
com.io7m.junsigned.ranges.UnsignedRangeInclusiveI
- All Implemented Interfaces:
UnsignedRangeInclusiveIType
An inclusive range with
int components.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds instances of typeUnsignedRangeInclusiveI. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder forUnsignedRangeInclusiveI.static UnsignedRangeInclusiveIcopyOf(UnsignedRangeInclusiveIType instance) Creates an immutable copy of aUnsignedRangeInclusiveITypevalue.booleanThis instance is equal to all instances ofUnsignedRangeInclusiveIthat have equal attribute values.inthashCode()Computes a hash code from attributes:lower,upper,interval.intinterval()Retrieve the number of values in the range[lower, upper].intlower()static UnsignedRangeInclusiveIof(int lower, int upper) Construct a new immutableUnsignedRangeInclusiveIinstance.toString()Prints the immutable valueUnsignedRangeInclusiveIwith attribute values.intupper()final UnsignedRangeInclusiveIwithLower(int value) Copy the current immutable object by setting a value for thelowerattribute.final UnsignedRangeInclusiveIwithUpper(int value) Copy the current immutable object by setting a value for theupperattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.junsigned.ranges.UnsignedRangeInclusiveIType
checkPreconditions, includesValue, isIncludedIn
-
Method Details
-
lower
public int lower()- Specified by:
lowerin interfaceUnsignedRangeInclusiveIType- Returns:
- The lower bound of the inclusive range.
-
upper
public int upper()- Specified by:
upperin interfaceUnsignedRangeInclusiveIType- Returns:
- The upper bound of the inclusive range.
-
interval
public int interval()Retrieve the number of values in the range
[lower, upper]. That is,(upper - lower) + 1.- Specified by:
intervalin interfaceUnsignedRangeInclusiveIType- Returns:
- The number of values in the range
-
withLower
Copy the current immutable object by setting a value for thelowerattribute. 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
thisobject
-
withUpper
Copy the current immutable object by setting a value for theupperattribute. 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
thisobject
-
equals
This instance is equal to all instances ofUnsignedRangeInclusiveIthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:lower,upper,interval. -
toString
Prints the immutable valueUnsignedRangeInclusiveIwith attribute values. -
of
Construct a new immutableUnsignedRangeInclusiveIinstance.- Parameters:
lower- The value for thelowerattributeupper- The value for theupperattribute- Returns:
- An immutable UnsignedRangeInclusiveI instance
-
copyOf
Creates an immutable copy of aUnsignedRangeInclusiveITypevalue. 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 UnsignedRangeInclusiveI instance
-
builder
Creates a builder forUnsignedRangeInclusiveI.UnsignedRangeInclusiveI.builder() .setLower(int) // requiredlower.setUpper(int) // requiredupper.build();- Returns:
- A new UnsignedRangeInclusiveI builder
-