Package com.io7m.junsigned.ranges
Class UnsignedRangeInclusiveL
java.lang.Object
com.io7m.junsigned.ranges.UnsignedRangeInclusiveL
- All Implemented Interfaces:
UnsignedRangeInclusiveLType
An inclusive range with
long components.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds instances of typeUnsignedRangeInclusiveL. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder forUnsignedRangeInclusiveL.static UnsignedRangeInclusiveLcopyOf(UnsignedRangeInclusiveLType instance) Creates an immutable copy of aUnsignedRangeInclusiveLTypevalue.booleanThis instance is equal to all instances ofUnsignedRangeInclusiveLthat have equal attribute values.inthashCode()Computes a hash code from attributes:lower,upper,interval.longinterval()Retrieve the number of values in the range[lower, upper].longlower()static UnsignedRangeInclusiveLof(long lower, long upper) Construct a new immutableUnsignedRangeInclusiveLinstance.toString()Prints the immutable valueUnsignedRangeInclusiveLwith attribute values.longupper()final UnsignedRangeInclusiveLwithLower(long value) Copy the current immutable object by setting a value for thelowerattribute.final UnsignedRangeInclusiveLwithUpper(long 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.UnsignedRangeInclusiveLType
checkPreconditions, includesValue, isIncludedIn
-
Method Details
-
lower
public long lower()- Specified by:
lowerin interfaceUnsignedRangeInclusiveLType- Returns:
- The lower bound of the inclusive range.
-
upper
public long upper()- Specified by:
upperin interfaceUnsignedRangeInclusiveLType- Returns:
- The upper bound of the inclusive range.
-
interval
public long interval()Retrieve the number of values in the range
[lower, upper]. That is,(upper - lower) + 1.- Specified by:
intervalin interfaceUnsignedRangeInclusiveLType- 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 ofUnsignedRangeInclusiveLthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:lower,upper,interval. -
toString
Prints the immutable valueUnsignedRangeInclusiveLwith attribute values. -
of
Construct a new immutableUnsignedRangeInclusiveLinstance.- Parameters:
lower- The value for thelowerattributeupper- The value for theupperattribute- Returns:
- An immutable UnsignedRangeInclusiveL instance
-
copyOf
Creates an immutable copy of aUnsignedRangeInclusiveLTypevalue. 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 UnsignedRangeInclusiveL instance
-
builder
Creates a builder forUnsignedRangeInclusiveL.UnsignedRangeInclusiveL.builder() .setLower(long) // requiredlower.setUpper(long) // requiredupper.build();- Returns:
- A new UnsignedRangeInclusiveL builder
-