@@ -103,7 +103,7 @@ public final class Hashids {
103
103
private final String separators ;
104
104
105
105
/**
106
- * Constructs a new Hashid with all default values.
106
+ * Constructs a new instance with all default values.
107
107
* <p>
108
108
* <ul>
109
109
* <li>no salt</li>
@@ -117,7 +117,7 @@ public Hashids() {
117
117
}
118
118
119
119
/**
120
- * Constructs a new Hashid with the specified salt and the default minimal hash length, alphabet and separators.
120
+ * Constructs a new instance with the specified salt and the default minimal hash length, alphabet and separators.
121
121
* <p>
122
122
* <ul>
123
123
* <li>no minimal hash length</li>
@@ -132,7 +132,7 @@ public Hashids(String salt) {
132
132
}
133
133
134
134
/**
135
- * Constructs a new Hashid with the specified salt and the minimal hash length and the default alphabet and
135
+ * Constructs a new instance with the specified salt and the minimal hash length and the default alphabet and
136
136
* separators.
137
137
* <p>
138
138
* <ul>
@@ -148,7 +148,7 @@ public Hashids(String salt, int minHashLength) {
148
148
}
149
149
150
150
/**
151
- * Constructs a new Hashid with the specified salt and alphabet and the default minimal hash length and separators.
151
+ * Constructs a new instance with the specified salt and alphabet and the default minimal hash length and separators.
152
152
* <p>
153
153
* <ul>
154
154
* <li>no minimal hash length</li>
@@ -163,7 +163,7 @@ public Hashids(String salt, String alphabet) {
163
163
}
164
164
165
165
/**
166
- * Constructs a new Hashid with the specified salt, minimal hash length and alphabet and the default separators.
166
+ * Constructs a new instance with the specified salt, minimal hash length and alphabet and the default separators.
167
167
* <p>
168
168
* <ul>
169
169
* <li>{@link #DEFAULT_SEPARATORS}</li>
@@ -178,7 +178,7 @@ public Hashids(String salt, int minHashLength, String alphabet) {
178
178
}
179
179
180
180
/**
181
- * Constructs a new Hashid with the specified salt, minimal hash length, alphabet and separators.
181
+ * Constructs a new instance with the specified salt, minimal hash length, alphabet and separators.
182
182
*
183
183
* @param salt the salt value
184
184
* @param minHashLength the minimal length of the hash
@@ -352,11 +352,11 @@ public Hashids build() {
352
352
* Encode number(s).
353
353
*
354
354
* @param numbers the number(s) to encode
355
- * @return the Hashid instance with the number(s) and the encoded string
355
+ * @return the hash
356
356
*/
357
- public Hashid encode (long ... numbers ) {
357
+ public String encode (long ... numbers ) {
358
358
if (numbers .length == 0 ) {
359
- return Hashid . EMPTY ;
359
+ return "" ;
360
360
}
361
361
return doEncode (numbers );
362
362
}
@@ -407,18 +407,18 @@ public String encodeHex(String hex) {
407
407
while (matcher .find ()) {
408
408
matched .add (Long .parseLong ("1" + matcher .group (), 16 ));
409
409
}
410
- return doEncode (toArray (matched )). toString () ;
410
+ return doEncode (toArray (matched ));
411
411
}
412
412
413
413
/**
414
414
* Decode an encoded string.
415
415
*
416
416
* @param hash the encoded string
417
- * @return the Hashid instance with the decoded hash and decoded number(s)
417
+ * @return the decoded number(s)
418
418
*/
419
- public Hashid decode (String hash ) {
419
+ public long [] decode (String hash ) {
420
420
if (isEmpty (hash )) {
421
- return Hashid . EMPTY ;
421
+ return new long [ 0 ] ;
422
422
}
423
423
return doDecode (hash , alphabet );
424
424
}
@@ -433,7 +433,7 @@ public long[] decodeLongNumbers(String hash) {
433
433
if (isEmpty (hash )) {
434
434
return new long [0 ];
435
435
}
436
- return doDecode (hash , alphabet ). numbers () ;
436
+ return doDecode (hash , alphabet );
437
437
}
438
438
439
439
/**
@@ -447,7 +447,7 @@ public int[] decodeIntegerNumbers(String hash) {
447
447
if (isEmpty (hash )) {
448
448
return new int [0 ];
449
449
}
450
- long [] numbers = doDecode (hash , alphabet ). numbers () ;
450
+ long [] numbers = doDecode (hash , alphabet );
451
451
int [] ints = new int [numbers .length ];
452
452
for (int idx = 0 ; idx < numbers .length ; idx ++) {
453
453
long number = numbers [idx ];
@@ -474,7 +474,7 @@ public String decodeHex(String hash) {
474
474
return sb .toString ();
475
475
}
476
476
477
- private Hashid doEncode (long ... numbers ) {
477
+ private String doEncode (long ... numbers ) {
478
478
int numberHashInt = 0 ;
479
479
for (int idx = 0 ; idx < numbers .length ; idx ++) {
480
480
if (numbers [idx ] < 0 || numbers [idx ] > MAX_NUMBER_VALUE ) {
@@ -525,10 +525,10 @@ private Hashid doEncode(long... numbers) {
525
525
result .replace (0 , result .length (), result .substring (startPos , startPos + minHashLength ));
526
526
}
527
527
}
528
- return new Hashid ( numbers , result .toString () );
528
+ return result .toString ();
529
529
}
530
530
531
- private Hashid doDecode (String hash , String alphabet ) {
531
+ private long [] doDecode (String hash , String alphabet ) {
532
532
final List <Long > result = new ArrayList <>();
533
533
int idx = 0 ;
534
534
String [] hashArray = hash .replaceAll ("[" + guards + "]" , " " ).split (" " );
@@ -550,8 +550,7 @@ private Hashid doDecode(String hash, String alphabet) {
550
550
result .add (unhash (subHash , alphabet ));
551
551
}
552
552
}
553
- long [] resultArray = toArray (result );
554
- return new Hashid (resultArray , hash );
553
+ return toArray (result );
555
554
}
556
555
557
556
private static String consistentShuffle (String alphabet , String salt ) {
0 commit comments