- java.lang.Object
-
- com.io7m.jranges.RangeInclusiveI
-
- All Implemented Interfaces:
RangeInclusiveIType
public final class RangeInclusiveI extends java.lang.Object implements RangeInclusiveIType
An inclusive range withintcomponents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRangeInclusiveI.BuilderBuilds instances of typeRangeInclusiveI.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RangeInclusiveI.Builderbuilder()Creates a builder forRangeInclusiveI.static RangeInclusiveIcopyOf(RangeInclusiveIType instance)Creates an immutable copy of aRangeInclusiveITypevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofRangeInclusiveIthat have equal attribute values.inthashCode()Computes a hash code from attributes:lower,upper.intlower()static RangeInclusiveIof(int lower, int upper)Construct a new immutableRangeInclusiveIinstance.java.lang.StringtoString()Prints the immutable valueRangeInclusiveIwith attribute values.intupper()RangeInclusiveIwithLower(int value)Copy the current immutable object by setting a value for thelowerattribute.RangeInclusiveIwithUpper(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, wait
-
Methods inherited from interface com.io7m.jranges.RangeInclusiveIType
checkPreconditions, includesValue, interval, isIncludedIn
-
-
-
-
Method Detail
-
lower
public int lower()
- Specified by:
lowerin interfaceRangeInclusiveIType- Returns:
- The lower bound of the inclusive range.
-
upper
public int upper()
- Specified by:
upperin interfaceRangeInclusiveIType- 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 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
public final RangeInclusiveI withUpper(int value)
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
public boolean equals(java.lang.Object another)
This instance is equal to all instances ofRangeInclusiveIthat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:lower,upper.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueRangeInclusiveIwith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
of
public static RangeInclusiveI of(int lower, int upper)
Construct a new immutableRangeInclusiveIinstance.- Parameters:
lower- The value for thelowerattributeupper- The value for theupperattribute- Returns:
- An immutable RangeInclusiveI instance
-
copyOf
public static RangeInclusiveI copyOf(RangeInclusiveIType instance)
Creates an immutable copy of aRangeInclusiveITypevalue. 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 forRangeInclusiveI.RangeInclusiveI.builder() .setLower(int) // requiredlower.setUpper(int) // requiredupper.build();- Returns:
- A new RangeInclusiveI builder
-
-