Comparable<Position>
, Position
public final class Index extends Object implements Position
Modifier and Type | Field | Description |
---|---|---|
int |
n |
The index number.
|
Modifier and Type | Method | Description |
---|---|---|
Index |
asIndex() |
Returns this index.
|
Key |
asKey() |
Throws an UnsupportedOperationException.
|
int |
compareTo(Position o) |
Compares this index with another given position.
|
boolean |
equals(@Nullable Object that) |
Returns true if that is an index and both have the same value.
|
int |
hashCode() |
Returns the hashcode of this index.
|
boolean |
isIndex() |
Returns true.
|
boolean |
isKey() |
Returns false.
|
static Index |
of(int index) |
Returns a new instance witch represents the given index in an array.
|
String |
toString() |
Returns the value of the index as a string.
|
public static Index of(int index)
index
- the given positionIndexOutOfBoundsException
- if the index is less than -1public int compareTo(Position o)
compareTo
in interface Comparable<Position>
compareTo
in interface Position
o
- the given positionpublic boolean isIndex()
public boolean isKey()
public Key asKey()
asKey
in interface Position
UnsupportedOperationException
- an Index can't be casted into an Keypublic Index asIndex()
public String toString()
public boolean equals(@Nullable Object that)
Copyright © 2019. All rights reserved.