Skip to content

Instantly share code, notes, and snippets.

@tfennelly
Created August 26, 2013 22:23
Show Gist options
  • Save tfennelly/6347384 to your computer and use it in GitHub Desktop.
Save tfennelly/6347384 to your computer and use it in GitHub Desktop.
package com.foxweave.mocksaas.model;
import com.cloudbees.weave.api.webhook.JSONSerializable;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.IOException;
/**
* @author <a href="mailto:[email protected]">[email protected]</a>
*/
public class Contact implements JSONSerializable {
@JsonProperty
public long id;
@JsonProperty
public String firstName;
@JsonProperty
public String lastName;
@JsonProperty
public String email;
@Override
public String toString() {
return id + ", " + firstName + " " + lastName + ", " + email;
}
@Override
public String toJSON() {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);
} catch (IOException e) {
throw new IllegalStateException("Unexpected error serializing Contact object to JSON String.", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment