commit | author | age
|
a18bfa
|
1 |
package com.codingapi.tx.model; |
Z |
2 |
|
|
3 |
|
|
4 |
import com.alibaba.fastjson.JSONObject; |
|
5 |
|
|
6 |
/** |
|
7 |
* Created by lorne on 2017/6/30. |
|
8 |
*/ |
|
9 |
public class TxServer { |
|
10 |
|
|
11 |
private int port; |
|
12 |
private String host; |
|
13 |
private int heart; |
|
14 |
private int delay; |
|
15 |
private int compensateMaxWaitTime; |
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
public int getPort() { |
|
20 |
return port; |
|
21 |
} |
|
22 |
|
|
23 |
public void setPort(int port) { |
|
24 |
this.port = port; |
|
25 |
} |
|
26 |
|
|
27 |
public String getHost() { |
|
28 |
return host; |
|
29 |
} |
|
30 |
|
|
31 |
public void setHost(String host) { |
|
32 |
this.host = host; |
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
public int getHeart() { |
|
37 |
return heart; |
|
38 |
} |
|
39 |
|
|
40 |
public void setHeart(int heart) { |
|
41 |
this.heart = heart; |
|
42 |
} |
|
43 |
|
|
44 |
public int getDelay() { |
|
45 |
return delay; |
|
46 |
} |
|
47 |
|
|
48 |
public void setDelay(int delay) { |
|
49 |
this.delay = delay; |
|
50 |
} |
|
51 |
|
|
52 |
public int getCompensateMaxWaitTime() { |
|
53 |
return compensateMaxWaitTime; |
|
54 |
} |
|
55 |
|
|
56 |
public void setCompensateMaxWaitTime(int compensateMaxWaitTime) { |
|
57 |
this.compensateMaxWaitTime = compensateMaxWaitTime; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public String toString() { |
|
62 |
return "host:" + host + ",port:" + port + ",heart:" + heart + ",delay:" + delay + ",compensateMaxWaitTime:" + compensateMaxWaitTime; |
|
63 |
} |
|
64 |
|
|
65 |
public static TxServer parser(String json) { |
|
66 |
try { |
|
67 |
JSONObject jsonObject = JSONObject.parseObject(json); |
|
68 |
TxServer txServer = new TxServer(); |
|
69 |
txServer.setPort(jsonObject.getInteger("port")); |
|
70 |
txServer.setHost(jsonObject.getString("ip")); |
|
71 |
txServer.setHeart(jsonObject.getInteger("heart")); |
|
72 |
txServer.setDelay(jsonObject.getInteger("delay")); |
|
73 |
txServer.setCompensateMaxWaitTime(jsonObject.getInteger("compensateMaxWaitTime")); |
|
74 |
return txServer; |
|
75 |
} catch (Exception e) { |
|
76 |
e.printStackTrace(); |
|
77 |
return null; |
|
78 |
} |
|
79 |
} |
|
80 |
} |