Package org.javagi.interop
Class VarargsUtil
java.lang.Object
org.javagi.interop.VarargsUtil
Utility functions to split an array of variadic arguments into a first
argument and a null-terminated array of remaining arguments.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
VarargsUtil
public VarargsUtil()
-
-
Method Details
-
first
public static <T> @Nullable T first(@Nullable T @Nullable [] array) Return the first array element.- Type Parameters:
T- array element type- Parameters:
array- input array, can benull- Returns:
- the first element, or
nullif the input array isnullor empty
-
rest
public static <T> @Nullable T @Nullable [] rest(@Nullable T @Nullable [] array) Return all but the first array elements, terminated with anull. For example,[1, 2, 3]returns[2, 3, null].- Type Parameters:
T- array element type- Parameters:
array- input array, can benull- Returns:
- a new array of all elements except the first, terminated with a
null, ornullif the input array isnullor empty
-