Generating Java with JCodeModel

Have you come across the misfortune of needing to auto-generate Java source code? Luckily, anything you’ve wanted to do with Java has already been done — and auto-generating Java is no different. I recently used JCodeModel to translate from JSON to Java — it worked great but it lacks any tutorial-style documentation. This article means to fill that gap. If you feel the need to go more in-depth, consult the the Javadoc. ...

February 21, 2016 · 4 min · Kevin Sookocheff

Why Java? Tales from a Python Convert

Whenever I tell people I’ve been working with Java I get the same reaction: “Yuck! Java? Why Java?” And, admittedly, I had the same reaction — at first. But over time, I’ve come to appreciate Java for its type safety, performance, and rock-solid tooling. I’ve also come to notice that this isn’t the Java I was used to — it’s been steadily improving over the last ten years. ...

November 20, 2015 · 10 min · Kevin Sookocheff

Including a local package as a Maven dependency

Lately I’ve been tasked with developing a Java library for internal use. For testing, its proved useful to package the library for local use. This article describes how to add a Jar file to a local Maven repository for use in your own testing and development. Create your local Maven repository Your local Maven repository lives within the project you are developing for. Creating your local repository is as simple as making a new directory. ...

November 12, 2015 · 2 min · Kevin Sookocheff

Writing Repeated BigQuery records using the Java Client Library

I’ve recently been working with Java via the Google Cloud Dataflow SDK. One problem I’ve had is working with the BigQuery Java Client. It was never entirely clear how to create a repeated record. This article explains how it works and how you can accomplish the same thing. First, you need to create a new TableRow. For this example, let’s assume we are logging events using a guid and a timestamp. ...

October 27, 2015 · 2 min · Kevin Sookocheff

From JSON to a Google API Client Library object

I have been working on a Cloud Dataflow project that parses incoming App Engine logs to generate status statistics such as numer of errors in the last 10 minutes. The incoming data is a JSON representation of a LogEntry object. A LogEntry object is represented in Java as a LogEntry class. The task I found myself in was converting the JSON representation of a LogEntry into the Java object for downstream processing. ...

October 25, 2015 · 2 min · Kevin Sookocheff

Creating a BigQuery Table using the Java Client Library

I haven’t been able to find great documentation on creating a BigQuery TableSchema using the Java Client Library. This blog post hopes to rectify that :). You can use the BigQuery sample code for an idea of how to create a client connection to BigQuery. Assuming you have the connection set up you can start by creating a new TableSchema. The TableSchema provides a method for setting the list of fields that make up the columns of your BigQuery Table. Those columns are defined as an Array of TableFieldSchema objects. ...

March 23, 2015 · 2 min · Kevin Sookocheff