SiftScience/jsonschema2pojo — pull request #3 by mwylde (2014-10-20 18:47:49+00:00)
Title: (For Jacob) Add support for schemas with type parameters

This PR adds support for parameterized schemas. It allows you to do something like:

```json
{
"title": "ListReponse",
"description": "JSON representation of List Response",
"type": "object",
"javaType": "com.sift.api.representations.ListResponseJson",
"properties": {
"data": {
"description": "A list of data items",
"type": "array",
"required": true,
"items": {
"type": "object",
"javaType": "T"
}
},
}
}
```

which will produce this code:

```java

package com.sift.api.representations;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
* ListReponse
*

* JSON representation of List Response
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"data"
})
public class ListResponseJson{

/**
* A list of data items
* (Required)
*
*/
@JsonProperty("data")
@NotNull
@Valid
public final List data;

private ListResponseJson(ListResponseJson.Builder builder) {
this.data = ((builder.data == null)?null:ImmutableList.copyOf(builder.data));
}

@JsonCreator
private ListResponseJson(
@JsonProperty("data")
List data) {
this.data = data;
}

public staticListResponseJson.Builder newBuilder() {
return new ListResponseJson.Builder();
}

public staticListResponseJson.Builder newBuilder(ListResponseJson from) {
ListResponseJson.Builder builder = new ListResponseJson.Builder();
builder.withData(((from.data == null)?null:ImmutableList.copyOf(from.data)));
return builder;
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}

@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}

@Override
public boolean equals(Object other) {
return EqualsBuilder.reflectionEquals(this, other);
}

public final static class Builder{

private List data = new ArrayList();

private Builder() {
}

public ListResponseJson build() {
return new ListResponseJson(this);
}

@JsonProperty("data")
public ListResponseJson.Builder withData(List data) {
this.data = data;
return this;
}
}

}
```

In order to make Jackson happy, I had to change the means by which it deserializes the json. Before, it was using the builder (as specified via `@JsonDeserializer`). However, Jackson isn't able to instantiate a properly typed builder, so instead we must use a `@JsonCreator` constructor.