diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 17:39:58 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 17:58:31 +0100 |
commit | 03833cd58c9ac42bf8414cb73258ddfec6b20447 (patch) | |
tree | 08823f49accd651009751e9398b19ec239255269 /jsonrpc | |
parent | 4aabaafc06f0bb7b26210a137276c31fed437af8 (diff) |
Add refactoring TODO.
Diffstat (limited to 'jsonrpc')
-rw-r--r-- | jsonrpc/src/main/java/com/orbekk/same/State.java | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/jsonrpc/src/main/java/com/orbekk/same/State.java b/jsonrpc/src/main/java/com/orbekk/same/State.java new file mode 100644 index 0000000..70ffa83 --- /dev/null +++ b/jsonrpc/src/main/java/com/orbekk/same/State.java @@ -0,0 +1,78 @@ +package com.orbekk.same; + +import java.util.Map; +import java.util.HashMap; + +public class State { + private long stateIteration = 0; + private Map<String, String> participants = new HashMap<String, String>(); + private String networkName = ""; + private String masterId = ""; + private String data = ""; + + public long getStateIteration() { + return stateIteration; + } + + public void setStateIteration(long stateIteration) { + this.stateIteration = stateIteration; + } + + public Map<String, String> getParticipants() { + return participants; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getMasterId() { + return masterId; + } + + public void setMasterId(String masterId) { + this.masterId = masterId; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + @Override + public String toString() { + StringBuilder participantsString = new StringBuilder(); + participantsString.append("["); + boolean first = true; + for (Map.Entry<String, String> e : participants.entrySet()) { + if (!first) { + participantsString.append(", "); + } + first = false; + participantsString.append(e.getKey()) + .append("(") + .append(e.getValue()) + .append(")"); + String clientId = e.getKey(); + String url = e.getValue(); + } + participantsString.append("]"); + + return String.format( + "State( \n" + + " stateIteration = %d,\n" + + " networkName = %s,\n" + + " masterId = %s,\n" + + " data = %s,\n" + + " participants = %s\n" + + ")", stateIteration, networkName, masterId, data, + participantsString); + } +} |