Skip to content

Instantly share code, notes, and snippets.

Rachel Tannenbaum rtannenbaum

  • Google
  • Chicago
Block or report user

Report or block rtannenbaum

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rtannenbaum
rtannenbaum / Item.java
Created Apr 1, 2014
Jackson serialization
View Item.java
@AutoValue
public abstract class Item
{
@JsonCreator
public static Item create(
@JsonProperty("sku") String sku,
@JsonProperty("barcode") String barcode,
@JsonProperty("backup") boolean backup,
@JsonProperty("removed") boolean removed,
View Item.json
{
"sku":"AB123_S",
"barcode":"038678561125",
"backup":false,
"removed":true,
"external_srr_reservation_id":0,
"external_rb_reservation_id":1
}
@rtannenbaum
rtannenbaum / ItemTest.java
Last active Aug 29, 2015
Serialization unit tests
View ItemTest.java
public class ItemTest {
private static ObjectMapper MAPPER = new ObjectMapperFactory().build();
private Item item = Item.create("AB123_S", "038678561125", false, true, 0, 1);
@Test
public void testJsonSerialization() throws IOException {
String json = MAPPER.writeValueAsString(item);
assertEquals(jsonFixture("fixtures/Item.json"), json);
}
@rtannenbaum
rtannenbaum / pom.xml
Last active Aug 29, 2015
Maven auto-value dependency
View pom.xml
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
</dependency>
@rtannenbaum
rtannenbaum / pom.xml
Created Apr 1, 2014
Maven annotation processor plugin
View pom.xml
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
@rtannenbaum
rtannenbaum / pom.xml
Created Apr 1, 2014
Maven compiler plugin
View pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
@rtannenbaum
rtannenbaum / Item.java
Created Apr 1, 2014
Item.java - Before
View Item.java
public class Item
{
private String sku;
private String barcode;
private boolean backup, removed;
private int external_srr_reservation_id;
@rtannenbaum
rtannenbaum / Item.java
Created Apr 1, 2014
Item.java - After
View Item.java
@AutoValue
public abstract class Item
{
public static Item create(String sku, String barcode, boolean backup, boolean removed,
int external_srr, int external_rb) {
return new AutoValue_Item(sku, barcode, backup, removed, external_srr, external_rb);
}
public abstract String sku();
View Item.java
@AutoValue
public abstract class Item
{
public static Item create(String sku, String barcode, boolean backup, boolean removed,
int external_srr, int external_rb) {
return new AutoValue_Item(sku, barcode, backup, removed, external_srr, external_rb);
}
public abstract String sku();
@rtannenbaum
rtannenbaum / AutoValue_Item.java
Created Apr 2, 2014
AutoValue generated source code
View AutoValue_Item.java
@javax.annotation.Generated("com.google.auto.value.processor.AutoValueProcessor")
final class AutoValue_Item extends Item {
private final String sku;
private final String barcode;
private final boolean backup;
private final boolean removed;
private final int external_srr_reservation_id;
private final int external_rb_reservation_id;
AutoValue_Item(
You can’t perform that action at this time.