Package adams.core
Class Range.SubRange
- java.lang.Object
-
- adams.core.Range.SubRange
-
- All Implemented Interfaces:
Serializable
,Comparable<Range.SubRange>
- Enclosing class:
- Range
public static class Range.SubRange extends Object implements Serializable, Comparable<Range.SubRange>
Represents a sub-range, either a single number of from-to.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Range.SubRange o)
Compares this subrange with the specified subrange for order.boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.Integer
getFrom()
Returns the "from" part of the sub-range.Integer
getTo()
Returns the "to" of the sub-range.boolean
hasTo()
Returns whether a "to" is available.boolean
isInRange(int index)
Checks whether the given index is within the limits of the sub-range.String
toString()
Returns a string representation of the sub-range.
-
-
-
Constructor Detail
-
SubRange
public SubRange(int from)
Initializes the sub-range as single number (0-based).- Parameters:
from
- the single number of the sub-range
-
SubRange
public SubRange(int from, Integer to)
Initializes the sub-range as range between (0-based) numbers.- Parameters:
from
- the start of the sub-range (incl)to
- the end of the sub-range (incl)
-
-
Method Detail
-
getFrom
public Integer getFrom()
Returns the "from" part of the sub-range.- Returns:
- the from
-
hasTo
public boolean hasTo()
Returns whether a "to" is available.- Returns:
- true if a "to" is available
-
getTo
public Integer getTo()
Returns the "to" of the sub-range.- Returns:
- the "to", null if not set
-
isInRange
public boolean isInRange(int index)
Checks whether the given index is within the limits of the sub-range.- Parameters:
index
- the (0-based) index to check- Returns:
- true if within range
-
compareTo
public int compareTo(Range.SubRange o)
Compares this subrange with the specified subrange for order. Returns a negative integer, zero, or a positive integer as this subrange is less than, equal to, or greater than the specified subrange. Uses the "from" as point of comparison and if those are equal, then the "to" (if available).- Specified by:
compareTo
in interfaceComparable<Range.SubRange>
- Parameters:
o
- the subrange to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
-