diff --git a/src/main/java/com/github/luben/zstd/Objects.java b/src/main/java/com/github/luben/zstd/Objects.java new file mode 100644 index 0000000..482fec3 --- /dev/null +++ b/src/main/java/com/github/luben/zstd/Objects.java @@ -0,0 +1,13 @@ +package com.github.luben.zstd; + +final class Objects { + + /** + * Checks constraints, that the fromIndex, size, length is not negative, and fromIndex + size is not greater than the size. + */ + static void checkFromIndexSize(int fromIndex, int size, int length) { + if ((length | fromIndex | size) < 0 || size > length - fromIndex) { + throw new IndexOutOfBoundsException(String.format("Range [%s, %