* Represents a token on the Cassandra ring.
| 28 | * Represents a token on the Cassandra ring. |
| 29 | */ |
| 30 | class Token { |
| 31 | constructor(value) { |
| 32 | this._value = value; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * @returns {{code: number, info: *|Object}} The type info for the |
| 37 | * type of the value of the token. |
| 38 | */ |
| 39 | getType() { |
| 40 | throw new Error('You must implement a getType function for this Token instance'); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @returns {*} The raw value of the token. |
| 45 | */ |
| 46 | getValue() { |
| 47 | return this._value; |
| 48 | } |
| 49 | |
| 50 | toString() { |
| 51 | return this._value.toString(); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Returns 0 if the values are equal, 1 if greater than other, -1 |
| 56 | * otherwise. |
| 57 | * |
| 58 | * @param {Token} other |
| 59 | * @returns {Number} |
| 60 | */ |
| 61 | compare(other) { |
| 62 | return this._value.compare(other._value); |
| 63 | } |
| 64 | |
| 65 | equals(other) { |
| 66 | return this.compare(other) === 0; |
| 67 | } |
| 68 | |
| 69 | inspect() { |
| 70 | return this.constructor.name + ' { ' + this.toString() + ' }'; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Represents a token from a Cassandra ring where the partitioner |
nothing calls this directly
no outgoing calls
no test coverage detected