Created
August 26, 2013 22:23
-
-
Save tfennelly/6347384 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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