|
13 | 13 | */ |
14 | 14 | public final class NumberUtils { |
15 | 15 |
|
16 | | - /** |
17 | | - * Bytes to int int. |
18 | | - * |
19 | | - * @param array the array |
20 | | - * @param offset the offset |
21 | | - * @param bigEndian the big endian |
22 | | - * @return the int |
23 | | - */ |
24 | | - @Deprecated(forRemoval = true) |
25 | | - public static int bytesToInt(@NotNull byte[] array, int offset, boolean bigEndian) { |
26 | | - |
27 | | - if (bigEndian) { |
28 | | - return makeInt(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]); |
29 | | - } |
30 | | - |
31 | | - return makeInt(array[offset + 3], array[offset + 2], array[offset + 1], array[offset]); |
32 | | - } |
33 | | - |
34 | | - /** |
35 | | - * Bytes to u int long. |
36 | | - * |
37 | | - * @param array the array |
38 | | - * @param offset the offset |
39 | | - * @param bigEndian the big endian |
40 | | - * @return the long |
41 | | - */ |
42 | | - @Deprecated(forRemoval = true) |
43 | | - public static long bytesToUInt(@NotNull byte[] array, int offset, boolean bigEndian) { |
44 | | - |
45 | | - long value = 0; |
46 | | - |
47 | | - if (bigEndian) { |
48 | | - value = makeInt(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]); |
49 | | - } else { |
50 | | - value = makeInt(array[offset + 3], array[offset + 2], array[offset + 1], array[offset]); |
51 | | - } |
52 | | - |
53 | | - return value & 0xFFFFFFFFL; |
54 | | - } |
55 | | - |
56 | | - /** |
57 | | - * Make int int. |
58 | | - * |
59 | | - * @param byte1 the byte 1 |
60 | | - * @param byte2 the byte 2 |
61 | | - * @param byte3 the byte 3 |
62 | | - * @param byte4 the byte 4 |
63 | | - * @return the int |
64 | | - */ |
65 | | - @Deprecated(forRemoval = true) |
66 | | - public static int makeInt(byte byte1, byte byte2, byte byte3, byte byte4) { |
67 | | - return (byte4 & 0xFF) << 24 | (byte3 & 0xFF) << 16 | (byte2 & 0xFF) << 8 | byte1 & 0xFF; |
68 | | - } |
69 | | - |
70 | | - /** |
71 | | - * Make long long. |
72 | | - * |
73 | | - * @param bytes the bytes |
74 | | - * @return the long |
75 | | - */ |
76 | | - @Deprecated(forRemoval = true) |
77 | | - public static long makeLong(@NotNull byte[] bytes) { |
78 | | - return ((long) bytes[7] & 0xFF) << 56 | ((long) bytes[6] & 0xFF) << 48 | ((long) bytes[5] & 0xFF) << 40 | |
79 | | - ((long) bytes[4] & 0xFF) << 32 | ((long) bytes[3] & 0xFF) << 24 | ((long) bytes[2] & 0xFF) << 16 | |
80 | | - ((long) bytes[1] & 0xFF) << 8 | (long) bytes[0] & 0xFF; |
81 | | - } |
82 | | - |
83 | 16 | /** |
84 | 17 | * Get a short value from a byte array. |
85 | 18 | * |
@@ -402,6 +335,84 @@ public static boolean toBoolean( |
402 | 335 | } |
403 | 336 | } |
404 | 337 |
|
| 338 | + /** |
| 339 | + * Returns {@code true} if the numbers are equal to each other |
| 340 | + * and {@code false} otherwise. |
| 341 | + * |
| 342 | + * @param first the first number. |
| 343 | + * @param second the second number to be compared with {@code first} for equality. |
| 344 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 345 | + * @since 9.7.0 |
| 346 | + */ |
| 347 | + public static boolean equals(byte first, byte second) { |
| 348 | + return first == second; |
| 349 | + } |
| 350 | + |
| 351 | + /** |
| 352 | + * Returns {@code true} if the numbers are equal to each other |
| 353 | + * and {@code false} otherwise. |
| 354 | + * |
| 355 | + * @param first the first number. |
| 356 | + * @param second the second number to be compared with {@code first} for equality. |
| 357 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 358 | + * @since 9.7.0 |
| 359 | + */ |
| 360 | + public static boolean equals(short first, short second) { |
| 361 | + return first == second; |
| 362 | + } |
| 363 | + |
| 364 | + /** |
| 365 | + * Returns {@code true} if the numbers are equal to each other |
| 366 | + * and {@code false} otherwise. |
| 367 | + * |
| 368 | + * @param first the first number. |
| 369 | + * @param second the second number to be compared with {@code first} for equality. |
| 370 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 371 | + * @since 9.7.0 |
| 372 | + */ |
| 373 | + public static boolean equals(int first, int second) { |
| 374 | + return first == second; |
| 375 | + } |
| 376 | + |
| 377 | + /** |
| 378 | + * Returns {@code true} if the numbers are equal to each other |
| 379 | + * and {@code false} otherwise. |
| 380 | + * |
| 381 | + * @param first the first number. |
| 382 | + * @param second the second number to be compared with {@code first} for equality. |
| 383 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 384 | + * @since 9.7.0 |
| 385 | + */ |
| 386 | + public static boolean equals(long first, long second) { |
| 387 | + return first == second; |
| 388 | + } |
| 389 | + |
| 390 | + /** |
| 391 | + * Returns {@code true} if the numbers are equal to each other |
| 392 | + * and {@code false} otherwise. |
| 393 | + * |
| 394 | + * @param first the first number. |
| 395 | + * @param second the second number to be compared with {@code first} for equality. |
| 396 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 397 | + * @since 9.7.0 |
| 398 | + */ |
| 399 | + public static boolean equals(float first, float second) { |
| 400 | + return first == second; |
| 401 | + } |
| 402 | + |
| 403 | + /** |
| 404 | + * Returns {@code true} if the numbers are equal to each other |
| 405 | + * and {@code false} otherwise. |
| 406 | + * |
| 407 | + * @param first the first number. |
| 408 | + * @param second the second number to be compared with {@code first} for equality. |
| 409 | + * @return {@code true} if the arguments are equal to each other and {@code false} otherwise. |
| 410 | + * @since 9.7.0 |
| 411 | + */ |
| 412 | + public static boolean equals(double first, double second) { |
| 413 | + return first == second; |
| 414 | + } |
| 415 | + |
405 | 416 | private NumberUtils() { |
406 | 417 | throw new IllegalArgumentException(); |
407 | 418 | } |
|
0 commit comments