Skip to content

Instantly share code, notes, and snippets.

@jmhertlein
Last active August 29, 2015 14:05
Show Gist options
  • Save jmhertlein/9be5faf641309bc9029f to your computer and use it in GitHub Desktop.
Save jmhertlein/9be5faf641309bc9029f to your computer and use it in GitHub Desktop.
Instead of this...
thinger: blah blah at x: 1, y: 1, z: 1
do this:
thinger:
msg: blah blah
x: 1
y: 1
z: 1
/////////////////////////////// here's a data class for you
public class Message implements ConfigurationSerializable {
private String message;
private int x, y, z;
public Message(String m, int x, int y, int z) {
this.message = m;
this.x = x;
this.y = y;
this.z = z;
}
//getters and setters
public Message deserialize(Map<String, Object> in) {
return new Message((String) in.get("message"), (Integer) in.get("x"), (Integer) in.get("y"), (Integer) in.get("z"));
}
public Map<String, Object> serialize() {
Map<String, Object> ret = new HashMap<String, Object>();
ret.put("message", message);
ret.put("x", x);
ret.put("y", y);
ret.put("z", z);
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment