Support (fixed-length) arrays of 16-bit integers
[ldk-java] / src / main / java / org / ldk / util / InternalUtils.java
index d9c3f6ef8364a4f89ec1c2653f5d747455325345..4e706ec10d24d232505a555533a544d3e89a6373 100644 (file)
@@ -8,6 +8,13 @@ public class InternalUtils {
         return arr;
     }
 
+    public static short[] check_arr_16_len(short[] arr, int length) throws IllegalArgumentException {
+        if (arr != null && arr.length != length) {
+            throw new IllegalArgumentException("Array must be of fixed size " + length + " but was of length " + arr.length);
+        }
+        return arr;
+    }
+
     public static byte[] convUInt5Array(UInt5[] u5s) {
         byte[] res = new byte[u5s.length];
         for (int i = 0; i < u5s.length; i++) {