Returns the byte value that is equal to value, if possible. @param value any value in the range of the byte type @return the byte value that equals value @throws IllegalArgumentException if value is greater than Byte#MAX_VALUE or less than
(long value)
| 58 | |
| 59 | |
| 60 | public static byte checkedCast(long value) { |
| 61 | byte result = (byte) value; |
| 62 | if (result != value) { |
| 63 | // don't use checkArgument here, to avoid boxing |
| 64 | throw new IllegalArgumentException("Out of range: " + value); |
| 65 | } |
| 66 | return result; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns the {@code byte} nearest in value to {@code value}. |