@Test public void testNullableLongArrayCopy() throws Exception { long[] input = {1L, 2L}; long[] nullInput = null; long[] output = CollectionUtils.nullableArrayCopy(input); long[] nullOutput = CollectionUtils.nullableArrayCopy(nullInput); assertThat(output.length, equalTo(input.length)); assertThat(output, not(sameInstance(input))); assertThat(nullOutput, nullValue()); }
public static <T> T[] nullableArrayCopy(T[] input) { return Optional.ofNullable(input).map(s -> Arrays.copyOf(s, s.length)).orElse(null); }
CollectionUtils { public static <T> T[] nullableArrayCopy(T[] input) { return Optional.ofNullable(input).map(s -> Arrays.copyOf(s, s.length)).orElse(null); } }
CollectionUtils { public static <T> T[] nullableArrayCopy(T[] input) { return Optional.ofNullable(input).map(s -> Arrays.copyOf(s, s.length)).orElse(null); } private  CollectionUtils(); }
CollectionUtils { public static <T> T[] nullableArrayCopy(T[] input) { return Optional.ofNullable(input).map(s -> Arrays.copyOf(s, s.length)).orElse(null); } private  CollectionUtils(); static T[] nullableArrayCopy(T[] input); static double[] nullableArrayCopy(double... input); static long[] nullableArrayCopy(long... input); static byte[] nullableArrayCopy(byte... input); static void nullOutByteArray(byte... input); static List<T> immutableOrEmptyList(List<T> input); static List<T> immutableListOrNull(List<T> input); static List<T> mutableListCopyOrNull(List<T> input); static Map<K, V> immutableOrEmptyMap(Map<K, V> input); static Map<K, V> immutableMapOrNull(Map<K, V> input); static SortedMap<K, V> immutableSortedOrEmptyMap(SortedMap<K, V> input); static SortedMap<K, V> immutableSortedMapOrNull(SortedMap<K, V> input); static Set<T> immutableOrEmptySet(Set<T> input); static Set<T> immutableSetOrNull(Set<T> input); }
CollectionUtils { public static <T> T[] nullableArrayCopy(T[] input) { return Optional.ofNullable(input).map(s -> Arrays.copyOf(s, s.length)).orElse(null); } private  CollectionUtils(); static T[] nullableArrayCopy(T[] input); static double[] nullableArrayCopy(double... input); static long[] nullableArrayCopy(long... input); static byte[] nullableArrayCopy(byte... input); static void nullOutByteArray(byte... input); static List<T> immutableOrEmptyList(List<T> input); static List<T> immutableListOrNull(List<T> input); static List<T> mutableListCopyOrNull(List<T> input); static Map<K, V> immutableOrEmptyMap(Map<K, V> input); static Map<K, V> immutableMapOrNull(Map<K, V> input); static SortedMap<K, V> immutableSortedOrEmptyMap(SortedMap<K, V> input); static SortedMap<K, V> immutableSortedMapOrNull(SortedMap<K, V> input); static Set<T> immutableOrEmptySet(Set<T> input); static Set<T> immutableSetOrNull(Set<T> input);  }