summaryrefslogtreecommitdiff
path: root/jsonrpc/src/main/java/com/orbekk/same/State.java
blob: 70ffa833c0ce09995ea4b4fe0bb8035f15fcf540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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);
    }
}