Skip to content

Commit cd4e53b

Browse files
committed
♻️ refactor: refactor codebase #2
1 parent 26f107b commit cd4e53b

File tree

11 files changed

+274
-114
lines changed

11 files changed

+274
-114
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.bot4j.base.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
6+
import java.io.Serializable;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
@JsonInclude(JsonInclude.Include.NON_NULL)
10+
public class BaseConnections implements Serializable {
11+
public BaseConnections() {
12+
super();
13+
}
14+
15+
private boolean debugging = false; // enable to trace log as debug mode
16+
private boolean skip = false; // skipping the action for sending message
17+
private boolean retry = false; // enable retry REST HTTP API when sending message got failure
18+
private int maxRetries = 2; // retry no. times when sending message, default is 2 times
19+
20+
public boolean isDebugging() {
21+
return debugging;
22+
}
23+
24+
public void setDebugging(boolean debugging) {
25+
this.debugging = debugging;
26+
}
27+
28+
public boolean isSkip() {
29+
return skip;
30+
}
31+
32+
public void setSkip(boolean skip) {
33+
this.skip = skip;
34+
}
35+
36+
public boolean isRetry() {
37+
return retry;
38+
}
39+
40+
public void setRetry(boolean retry) {
41+
this.retry = retry;
42+
}
43+
44+
public int getMaxRetries() {
45+
return maxRetries;
46+
}
47+
48+
public void setMaxRetries(int maxRetries) {
49+
this.maxRetries = maxRetries;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
return String.format("connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
55+
this.debugging, this.skip, this.retry, this.maxRetries);
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.bot4j.base.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import org.unify4j.common.UniqueId4j;
6+
7+
import java.io.Serializable;
8+
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
11+
public class BaseOptions implements Serializable {
12+
public BaseOptions() {
13+
super();
14+
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
15+
}
16+
17+
private String requestId;
18+
19+
public String getRequestId() {
20+
return requestId;
21+
}
22+
23+
public void setRequestId(String requestId) {
24+
this.requestId = requestId;
25+
}
26+
}

Diff for: plugin/src/main/groovy/org/bot4j/slack/model/request/SlackConnections.java

+3-42
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,17 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5-
6-
import java.io.Serializable;
5+
import org.bot4j.base.request.BaseConnections;
76

87
@JsonIgnoreProperties(ignoreUnknown = true)
98
@JsonInclude(JsonInclude.Include.NON_NULL)
10-
public class SlackConnections implements Serializable {
9+
public class SlackConnections extends BaseConnections {
1110
public SlackConnections() {
1211
super();
1312
}
1413

15-
private boolean debugging = false; // enable to trace log as debug mode
16-
private boolean skip = false; // skipping the action for sending message
17-
private boolean retry = false; // enable retry REST HTTP Telegram API when sending message got failure
18-
private int maxRetries = 2; // retry no. times when sending message, default is 2 times
19-
20-
public boolean isDebugging() {
21-
return debugging;
22-
}
23-
24-
public void setDebugging(boolean debugging) {
25-
this.debugging = debugging;
26-
}
27-
28-
public boolean isSkip() {
29-
return skip;
30-
}
31-
32-
public void setSkip(boolean skip) {
33-
this.skip = skip;
34-
}
35-
36-
public boolean isRetry() {
37-
return retry;
38-
}
39-
40-
public void setRetry(boolean retry) {
41-
this.retry = retry;
42-
}
43-
44-
public int getMaxRetries() {
45-
return maxRetries;
46-
}
47-
48-
public void setMaxRetries(int maxRetries) {
49-
this.maxRetries = maxRetries;
50-
}
51-
5214
@Override
5315
public String toString() {
54-
return String.format("Slack connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
55-
this.debugging, this.skip, this.retry, this.maxRetries);
16+
return String.format("%s %s", "Slack", super.toString());
5617
}
5718
}

Diff for: plugin/src/main/groovy/org/bot4j/slack/model/request/SlackOptions.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5-
import org.unify4j.common.UniqueId4j;
6-
7-
import java.io.Serializable;
5+
import org.bot4j.base.request.BaseOptions;
86

97
@JsonIgnoreProperties(ignoreUnknown = true)
108
@JsonInclude(JsonInclude.Include.NON_NULL)
11-
public class SlackOptions implements Serializable {
9+
public class SlackOptions extends BaseOptions {
1210
public SlackOptions() {
1311
super();
14-
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
15-
}
16-
17-
private String requestId;
18-
19-
public String getRequestId() {
20-
return requestId;
21-
}
22-
23-
public void setRequestId(String requestId) {
24-
this.requestId = requestId;
2512
}
2613
}

Diff for: plugin/src/main/groovy/org/bot4j/telegram/model/request/TelegramConnections.java

+3-42
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,17 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5-
6-
import java.io.Serializable;
5+
import org.bot4j.base.request.BaseConnections;
76

87
@JsonIgnoreProperties(ignoreUnknown = true)
98
@JsonInclude(JsonInclude.Include.NON_NULL)
10-
public class TelegramConnections implements Serializable {
9+
public class TelegramConnections extends BaseConnections {
1110
public TelegramConnections() {
1211
super();
1312
}
1413

15-
private boolean debugging = false; // enable to trace log as debug mode
16-
private boolean skip = false; // skipping the action for sending message
17-
private boolean retry = false; // enable retry REST HTTP Telegram API when sending message got failure
18-
private int maxRetries = 2; // retry no. times when sending message, default is 2 times
19-
20-
public boolean isDebugging() {
21-
return debugging;
22-
}
23-
24-
public void setDebugging(boolean debugging) {
25-
this.debugging = debugging;
26-
}
27-
28-
public boolean isSkip() {
29-
return skip;
30-
}
31-
32-
public void setSkip(boolean skip) {
33-
this.skip = skip;
34-
}
35-
36-
public boolean isRetry() {
37-
return retry;
38-
}
39-
40-
public void setRetry(boolean retry) {
41-
this.retry = retry;
42-
}
43-
44-
public int getMaxRetries() {
45-
return maxRetries;
46-
}
47-
48-
public void setMaxRetries(int maxRetries) {
49-
this.maxRetries = maxRetries;
50-
}
51-
5214
@Override
5315
public String toString() {
54-
return String.format("Telegram connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
55-
this.debugging, this.skip, this.retry, this.maxRetries);
16+
return String.format("%s %s", "Telegram", super.toString());
5617
}
5718
}

Diff for: plugin/src/main/groovy/org/bot4j/telegram/model/request/TelegramOptions.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5-
import org.unify4j.common.UniqueId4j;
6-
7-
import java.io.Serializable;
5+
import org.bot4j.base.request.BaseOptions;
86

97
@JsonIgnoreProperties(ignoreUnknown = true)
108
@JsonInclude(JsonInclude.Include.NON_NULL)
11-
public class TelegramOptions implements Serializable {
9+
public class TelegramOptions extends BaseOptions {
1210
public TelegramOptions() {
1311
super();
14-
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
15-
}
16-
17-
private String requestId;
18-
19-
public String getRequestId() {
20-
return requestId;
21-
}
22-
23-
public void setRequestId(String requestId) {
24-
this.requestId = requestId;
2512
}
2613
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.bot4j.viber.model.builder;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import org.bot4j.viber.model.request.ViberConnections;
5+
6+
import java.io.Serializable;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public class ViberConnectionBuilder implements Serializable {
10+
public ViberConnectionBuilder() {
11+
super();
12+
}
13+
14+
private boolean debugging = false; // enable to trace log as debug mode
15+
private boolean skip = false; // skipping the action for sending message
16+
private boolean retry = false; // enable retry REST HTTP API when sending message got failure
17+
private int maxRetries = 2; // retry no. times when sending message, default is 2 times
18+
19+
public ViberConnectionBuilder debugging(boolean value) {
20+
this.debugging = value;
21+
return this;
22+
}
23+
24+
public ViberConnectionBuilder skip(boolean value) {
25+
this.skip = value;
26+
return this;
27+
}
28+
29+
public ViberConnectionBuilder retry(boolean value) {
30+
this.retry = value;
31+
return this;
32+
}
33+
34+
public ViberConnectionBuilder maxRetries(int value) {
35+
this.maxRetries = value;
36+
return this;
37+
}
38+
39+
public ViberConnections build() {
40+
ViberConnections e = new ViberConnections();
41+
e.setDebugging(debugging);
42+
e.setSkip(skip);
43+
e.setRetry(retry);
44+
e.setMaxRetries(maxRetries);
45+
return e;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.bot4j.viber.model.builder;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import org.bot4j.viber.model.request.ViberOptions;
5+
import org.unify4j.common.UniqueId4j;
6+
7+
import java.io.Serializable;
8+
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
public class ViberOptionBuilder implements Serializable {
11+
public ViberOptionBuilder() {
12+
super();
13+
this.requestId = String.valueOf(UniqueId4j.getUniqueId19());
14+
}
15+
16+
private String requestId;
17+
18+
public ViberOptionBuilder requestId(String value) {
19+
this.requestId = value;
20+
return this;
21+
}
22+
23+
public ViberOptions build() {
24+
ViberOptions e = new ViberOptions();
25+
e.setRequestId(this.requestId);
26+
return e;
27+
}
28+
}

0 commit comments

Comments
 (0)