Revision 393963333639 () - Diff

Link to this snippet: https://friendpaste.com/3kAPhCc7987hSLMNaHiS0k
Embed:
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
public String getRequestString() throws MQException {
RequestBuilder req = new RequestBuilder();
req.sessionNumber('0', 3)
.version('0', 3)
.transaction('X', 4)
.language('X', 2)
.callersPhoneNumber('0', 16)
.customerNumber(' ', 16)
.nrUnsuccessfulCalls('0', 3);
return req.build();
}

private class RequestBuilder {
private StringBuilder b = new StringBuilder();
public RequestBuilder callersPhoneNumber(char pad, int width) {
add(Helper.leftRightFilled(true, getCallersPhoneNumber(), pad, width));
return this;
}
public RequestBuilder customerNumber(char pad, int width) throws MQException {
add(Helper.leftRightFilled(false, dynamicSettingMQ.getCustomerNumber(), pad, width));
return this;
}
public RequestBuilder language(char pad, int width) throws MQException {
add(Helper.leftRightFilled(true, getLanguage(), pad, width));
return this;
}
public RequestBuilder nrUnsuccessfulCalls(char pad, int width) throws MQException {
add(Helper.leftRightFilled(true, dynamicSettingMQ.getNumberOfUnsucceededCalls(), pad, width));
return this;
}
public RequestBuilder sessionNumber(char pad, int width) throws MQException {
add(Helper.leftRightFilled(true, getSessionNumberAndIncreaseIt(), pad, width));
return this;
}
public RequestBuilder transaction(char pad, int width) throws MQException {
add(Helper.leftRightFilled(true, getTransaction(), pad, width));
return this;
}
public RequestBuilder version(char pad, int width) throws MQException {
add(Helper.leftRightFilled(true, getVersion(), pad, width));
return this;
}
public String build() {
return b.toString();
}
private void add(String str) {
b.append(str);
}
}