private static void throwBufferSizeException(StructBuffer<?, ?> buf, int size) { throw new IllegalArgumentException( "Number of remaining struct values in buffer is " + buf.remaining() + ", must be at least " + size); }
private static void throwBufferSizeGTException(StructBuffer<?, ?> buf, int size) { throw new IllegalArgumentException( "Number of remaining buffer elements is " + buf.remaining() + ", must be at most " + size + "."); }
public static void checkBufferGT(StructBuffer<?, ?> buf, int size) { if (size < buf.remaining()) throwBufferSizeGTException(buf, size); }
/** * Helper method to ensure a {@link StructBuffer} has enough capacity. * * @param buf the buffer to check * @param size the minimum buffer capacity * @throws IllegalArgumentException */ public static void checkBuffer(StructBuffer<?, ?> buf, int size) { if (buf.remaining() < size) { throwBufferSizeException(buf, size); } }