You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ((encoded.length - index) < (codeVarint.length + 1)) {
148
-
thrownewIllegalArgumentException("The value to decode must be non empty byte array, min length = " + (codeVarint.length + 1) + ", actual = " + encoded.length + ".");
169
+
thrownewIllegalArgumentException(
170
+
"The value to decode must be a non-empty byte array with a minimum length of "
171
+
+ (codeVarint.length + 1) + " bytes, but the actual length is " + encoded.length + " bytes.");
149
172
}
150
173
151
174
if (!IntStream.range(0, codeVarint.length).allMatch(i -> codeVarint[i] == encoded[i + index])) {
152
-
thrownewIllegalArgumentException("The value to decode is not encoded with " + toString() + ".");
175
+
thrownewIllegalArgumentException(
176
+
"The provided value is not encoded with this codec: " + toString() + ".");
153
177
}
154
178
155
179
returnArrays.copyOfRange(encoded, index + codeVarint.length, encoded.length - index);
@@ -176,4 +200,58 @@ public boolean equals(Object obj) {
176
200
publicStringtoString() {
177
201
return"Multicodec [name=" + name + ", tag=" + tag + ", code=" + code + "]";
178
202
}
203
+
204
+
/**
205
+
* Returns the length of this codec's varint code in bytes.
206
+
*
207
+
* @return varint length
208
+
*/
209
+
publicintlength() {
210
+
returncodeVarint.length;
211
+
}
212
+
213
+
/**
214
+
* Returns the varint-encoded form of this codec's code.
215
+
*
216
+
* @return varint byte array
217
+
*/
218
+
publicbyte[] varint() {
219
+
returncodeVarint;
220
+
}
221
+
222
+
/**
223
+
* Returns this codec's category tag.
224
+
*
225
+
* @return the tag
226
+
*/
227
+
publicTagtag() {
228
+
returntag;
229
+
}
230
+
231
+
/**
232
+
* Returns this codec's name.
233
+
*
234
+
* @return the name
235
+
*/
236
+
publicStringname() {
237
+
returnname;
238
+
}
239
+
240
+
/**
241
+
* Returns this codec's numeric code.
242
+
*
243
+
* @return the numeric code
244
+
*/
245
+
publiclongcode() {
246
+
returncode;
247
+
}
248
+
249
+
/**
250
+
* Returns this codec's registration status.
251
+
*
252
+
* @return the status, or {@code null} if unspecified
0 commit comments