Package io.github.jwharm.javagi.interop
Class VarargsUtil
java.lang.Object
io.github.jwharm.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
-
Method Summary
-
Constructor Details
-
VarargsUtil
public VarargsUtil()
-
-
Method Details
-
first
@Nullable public static <T> 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
null
if the input array isnull
or empty
-
rest
@Nullable public static <T> 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
, ornull
if the input array isnull
or empty
-