private static void checkPayloadCapacity(int chunkPayloadCapacity,
                                           boolean reserveNextChunkIdField) {
    if (chunkPayloadCapacity <= 0) {
      throw new IllegalArgumentException("Can't append chunk with payloadCapacity(=" + chunkPayloadCapacity + ") <= 0");
    }

    int maxPayloadSize = reserveNextChunkIdField ?
                         MAX_PAYLOAD_SIZE_WITH_NEXT_CHUNK :
                         MAX_PAYLOAD_SIZE_WITHOUT_NEXT_CHUNK;
    if (chunkPayloadCapacity > maxPayloadSize) {
      throw new IllegalArgumentException(
        "payloadCapacity(=" + chunkPayloadCapacity + ") > MAX(" + maxPayloadSize + ")"
      );
    }
  }
private static void checkPayloadCapacity(int chunkPayloadCapacity,
                                           boolean reserveNextChunkIdField)