Created
September 21, 2012 15:13
-
-
Save AVGP/3762089 to your computer and use it in GitHub Desktop.
Sample Java Library
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 org.avgp.sample; | |
import org.avgp.sample.User; | |
import org.json.JSONString; | |
public class Message implements JSONString { | |
protected User sender; | |
protected User receipient; | |
protected String content; | |
public Message(User from, User to, String content) { | |
this.sender = from; | |
this.receipient = to; | |
this.content = content; | |
} | |
public String toJSONString() { | |
return "{sender: " + this.sender.toJSONString() + ", receipient: " + this.receipient.toJSONString() + ", content: \"" + this.content + "\"}"; | |
} | |
} |
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 org.avgp.sample; | |
import java.util.UUID; | |
import org.json.JSONString; | |
public class User implements JSONString { | |
private String name; | |
private UUID id; | |
public User(String name) { | |
this.name = name; | |
this.id = UUID.randomUUID(); | |
} | |
public String getName() { | |
return this.name; | |
} | |
public UUID getId() { | |
return this.id; | |
} | |
public String toJSONString() { | |
return "{name: \"" + this.name + "\", id: \"" + this.id.toString() + "\"}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment