@Test void streamByte() { byte[] bytes = RandomValues.randomByteArray(10, 20); Byte[] resultAsArray = ArrayUtil.stream(bytes).toArray(Byte[]::new); assertThat(resultAsArray.length, is(bytes.length)); for (int i = 0; i < resultAsArray.length; i++) { assertThat(resultAsArray[i], is(bytes[i])); } }
public static Stream<Boolean> stream(boolean[] booleans) { return IntStream.range(0, booleans.length).mapToObj(i -> booleans[i]); }
ArrayUtil extends UtilityClass { public static Stream<Boolean> stream(boolean[] booleans) { return IntStream.range(0, booleans.length).mapToObj(i -> booleans[i]); } }
ArrayUtil extends UtilityClass { public static Stream<Boolean> stream(boolean[] booleans) { return IntStream.range(0, booleans.length).mapToObj(i -> booleans[i]); }  }
ArrayUtil extends UtilityClass { public static Stream<Boolean> stream(boolean[] booleans) { return IntStream.range(0, booleans.length).mapToObj(i -> booleans[i]); }  @SuppressWarnings("unchecked") static T[] newArray(Class<T> elementType, int size); @SuppressWarnings("unchecked") static T[] newArray(TypeToken<T> elementType, int size); @SuppressWarnings("unchecked") static IntFunction<T[]> generator(Class<? super T> elementClass); @SuppressWarnings("unchecked") static IntFunction<T[]> generator(T prototype); @SuppressWarnings("unchecked") static T[] arrayOf(int size, T value); static char[] arrayOf(int size, char value); static boolean[] arrayOf(int size, boolean value); static byte[] arrayOf(int size, byte value); static short[] arrayOf(int size, short value); static int[] arrayOf(int size, int value); static long[] arrayOf(int size, long value); static float[] arrayOf(int size, float value); static double[] arrayOf(int size, double value); static Stream<Boolean> stream(boolean[] booleans); static Stream<Byte> stream(byte[] bytes); static Stream<Character> stream(char[] chars); static Stream<Short> stream(short[] shorts); static Stream<Float> stream(float[] floats); }
ArrayUtil extends UtilityClass { public static Stream<Boolean> stream(boolean[] booleans) { return IntStream.range(0, booleans.length).mapToObj(i -> booleans[i]); }  @SuppressWarnings("unchecked") static T[] newArray(Class<T> elementType, int size); @SuppressWarnings("unchecked") static T[] newArray(TypeToken<T> elementType, int size); @SuppressWarnings("unchecked") static IntFunction<T[]> generator(Class<? super T> elementClass); @SuppressWarnings("unchecked") static IntFunction<T[]> generator(T prototype); @SuppressWarnings("unchecked") static T[] arrayOf(int size, T value); static char[] arrayOf(int size, char value); static boolean[] arrayOf(int size, boolean value); static byte[] arrayOf(int size, byte value); static short[] arrayOf(int size, short value); static int[] arrayOf(int size, int value); static long[] arrayOf(int size, long value); static float[] arrayOf(int size, float value); static double[] arrayOf(int size, double value); static Stream<Boolean> stream(boolean[] booleans); static Stream<Byte> stream(byte[] bytes); static Stream<Character> stream(char[] chars); static Stream<Short> stream(short[] shorts); static Stream<Float> stream(float[] floats);  }