diff options
Diffstat (limited to 'guava/src/com/google/common/primitives/Bytes.java')
-rw-r--r-- | guava/src/com/google/common/primitives/Bytes.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/guava/src/com/google/common/primitives/Bytes.java b/guava/src/com/google/common/primitives/Bytes.java index d9c5e1f..92f7805 100644 --- a/guava/src/com/google/common/primitives/Bytes.java +++ b/guava/src/com/google/common/primitives/Bytes.java @@ -38,10 +38,6 @@ import java.util.RandomAccess; * treat bytes as signed or unsigned are found in {@link SignedBytes} and {@link * UnsignedBytes}. * - * <p>See the Guava User Guide article on <a href= - * "http://code.google.com/p/guava-libraries/wiki/PrimitivesExplained"> - * primitive utilities</a>. - * * @author Kevin Bourrillion * @since 1.0 */ @@ -214,21 +210,20 @@ public final class Bytes { } /** - * Returns an array containing each value of {@code collection}, converted to - * a {@code byte} value in the manner of {@link Number#byteValue}. + * Copies a collection of {@code Byte} instances into a new array of + * primitive {@code byte} values. * * <p>Elements are copied from the argument collection as if by {@code * collection.toArray()}. Calling this method is as thread-safe as calling * that method. * - * @param collection a collection of {@code Number} instances + * @param collection a collection of {@code Byte} objects * @return an array containing the same values as {@code collection}, in the * same order, converted to primitives * @throws NullPointerException if {@code collection} or any of its elements * is null - * @since 1.0 (parameter was {@code Collection<Byte>} before 12.0) */ - public static byte[] toArray(Collection<? extends Number> collection) { + public static byte[] toArray(Collection<Byte> collection) { if (collection instanceof ByteArrayAsList) { return ((ByteArrayAsList) collection).toByteArray(); } @@ -238,7 +233,7 @@ public final class Bytes { byte[] array = new byte[len]; for (int i = 0; i < len; i++) { // checkNotNull for GWT (do not optimize) - array[i] = ((Number) checkNotNull(boxedArray[i])).byteValue(); + array[i] = (Byte) checkNotNull(boxedArray[i]); } return array; } @@ -325,8 +320,7 @@ public final class Bytes { @Override public Byte set(int index, Byte element) { checkElementIndex(index, size()); byte oldValue = array[start + index]; - // checkNotNull for GWT (do not optimize) - array[start + index] = checkNotNull(element); + array[start + index] = checkNotNull(element); // checkNotNull for GWT (do not optimize) return oldValue; } @@ -377,7 +371,7 @@ public final class Bytes { } byte[] toByteArray() { - // Arrays.copyOfRange() is not available under GWT + // Arrays.copyOfRange() requires Java 6 int size = size(); byte[] result = new byte[size]; System.arraycopy(array, start, result, 0, size); |