Ranamed SafeUnsigned to UnsafeNarrowing

This commit is contained in:
Collin Smith 2020-08-11 17:56:40 -07:00
parent d8679e34e1
commit 088cde3b9e
3 changed files with 11 additions and 11 deletions

View File

@ -62,7 +62,7 @@ class BitConstraints {
public static byte safe8u(short i) {
if (!BitUtils.isUnsigned(i, Byte.SIZE)) {
throw new SafeUnsigned(i);
throw new UnsafeNarrowing(i);
}
return (byte) i;
@ -70,7 +70,7 @@ class BitConstraints {
public static short safe16u(int i) {
if (!BitUtils.isUnsigned(i, Short.SIZE)) {
throw new SafeUnsigned(i);
throw new UnsafeNarrowing(i);
}
return (short) i;
@ -78,7 +78,7 @@ class BitConstraints {
public static int safe32u(long i) {
if (!BitUtils.isUnsigned(i, Integer.SIZE)) {
throw new SafeUnsigned(i);
throw new UnsafeNarrowing(i);
}
return (int) i;
@ -86,7 +86,7 @@ class BitConstraints {
public static long safe64u(long i) {
if (!BitUtils.isUnsigned(i, Long.SIZE)) {
throw new SafeUnsigned(i);
throw new UnsafeNarrowing(i);
}
return (long) i;

View File

@ -288,7 +288,7 @@ public class ByteInput {
/**
* Reads an unsigned byte as a {@code byte}.
*
* @throws SafeUnsigned if the read value is larger than 7 bits.
* @throws UnsafeNarrowing if the read value is larger than 7 bits.
*
* @see #read8u()
*/
@ -306,7 +306,7 @@ public class ByteInput {
/**
* Reads an unsigned 16-bit short integer as a {@code short}.
*
* @throws SafeUnsigned if the read value is larger than 15 bits.
* @throws UnsafeNarrowing if the read value is larger than 15 bits.
*
* @see #read16u()
*/
@ -324,7 +324,7 @@ public class ByteInput {
/**
* Reads an unsigned 32-bit integer as an {@code int}.
*
* @throws SafeUnsigned if the read value is larger than 31 bits.
* @throws UnsafeNarrowing if the read value is larger than 31 bits.
*
* @see #read32u()
*/
@ -342,7 +342,7 @@ public class ByteInput {
/**
* Reads an unsigned 64-bit long integer as a {@code long}.
*
* @throws SafeUnsigned if the read value is larger than 63 bits.
* @throws UnsafeNarrowing if the read value is larger than 63 bits.
*
* @see #read32u()
*/

View File

@ -1,10 +1,10 @@
package com.riiablo.io;
public class SafeUnsigned extends RuntimeException {
public class UnsafeNarrowing extends RuntimeException {
public final long value;
SafeUnsigned(long value) {
super("value(" + value + ") is not unsigned!");
UnsafeNarrowing(long value) {
super("value(" + value + ") cannot be safely narrowed!");
this.value = value;
}