Last active
August 29, 2015 14:05
-
-
Save jmhertlein/9be5faf641309bc9029f 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
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