Skip to content

Commit 9d29f7b

Browse files
committed
Moving around some methods in Util.java
1 parent d85b422 commit 9d29f7b

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/main/java/at/favre/lib/bytes/Util.java

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ static byte[] concat(byte[]... arrays) {
6363
return result;
6464
}
6565

66+
67+
/**
68+
* Combines a single argument with a vararg to a single array
69+
*
70+
* @param firstByte first arg
71+
* @param moreBytes varargs
72+
* @return array containing all args
73+
*/
74+
static byte[] concatVararg(byte firstByte, byte[] moreBytes) {
75+
if (moreBytes == null) {
76+
return new byte[]{firstByte};
77+
} else {
78+
return concat(new byte[]{firstByte}, moreBytes);
79+
}
80+
}
81+
6682
/**
6783
* Returns the start position of the first occurrence of the specified {@code
6884
* target} within {@code array}, or {@code -1} if there is no such occurrence.
@@ -189,21 +205,6 @@ static void reverse(byte[] array, int fromIndex, int toIndex) {
189205
}
190206
}
191207

192-
/**
193-
* Combines a single argument with a vararg to a single array
194-
*
195-
* @param firstByte first arg
196-
* @param moreBytes varargs
197-
* @return array containing all args
198-
*/
199-
static byte[] concatVararg(byte firstByte, byte[] moreBytes) {
200-
if (moreBytes == null) {
201-
return new byte[]{firstByte};
202-
} else {
203-
return concat(new byte[]{firstByte}, moreBytes);
204-
}
205-
}
206-
207208
/**
208209
* Light shift of whole byte array by shiftBitCount bits.
209210
* This method will alter the input byte array.
@@ -332,21 +333,6 @@ static byte[] toArray(Collection<java.lang.Byte> collection) {
332333
return array;
333334
}
334335

335-
/**
336-
* Converts given array to list of boxed bytes. Will create a new list
337-
* and not reuse the array reference.
338-
*
339-
* @param array to convert
340-
* @return list with same length and content as array
341-
*/
342-
static List<java.lang.Byte> toList(byte[] array) {
343-
List<java.lang.Byte> list = new ArrayList<>(array.length);
344-
for (byte b : array) {
345-
list.add(b);
346-
}
347-
return list;
348-
}
349-
350336
/**
351337
* Converts this primitive array to an boxed object array.
352338
* Will create a new array and not reuse the array reference.
@@ -362,6 +348,21 @@ static java.lang.Byte[] toBoxedArray(byte[] array) {
362348
return objectArray;
363349
}
364350

351+
/**
352+
* Converts given array to list of boxed bytes. Will create a new list
353+
* and not reuse the array reference.
354+
*
355+
* @param array to convert
356+
* @return list with same length and content as array
357+
*/
358+
static List<java.lang.Byte> toList(byte[] array) {
359+
List<java.lang.Byte> list = new ArrayList<>(array.length);
360+
for (byte b : array) {
361+
list.add(b);
362+
}
363+
return list;
364+
}
365+
365366
/**
366367
* Converts this object array to an primitives type array.
367368
* Will create a new array and not reuse the array reference.

0 commit comments

Comments
 (0)