Skip to content

Commit a66d962

Browse files
committed
♻️ refactor: update codebase #5 #2
1 parent 75cfea6 commit a66d962

File tree

9 files changed

+185
-7
lines changed

9 files changed

+185
-7
lines changed

Diff for: plugin/src/main/groovy/org/bot4j/telegram/message/HtmlBuilder.java

+38-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
import java.util.Date;
1111
import java.util.TimeZone;
1212

13-
public class HtmlBuilder {
13+
// @formatter:off
14+
public class HtmlBuilder implements MessageBuilder<HtmlBuilder> {
1415
protected final StringBuilder message;
1516

1617
public HtmlBuilder() {
1718
this.message = new StringBuilder();
1819
}
1920

21+
@Override
2022
public HtmlBuilder icon(TelegramIconMode mode) {
2123
if (mode == null) {
2224
return this;
@@ -25,6 +27,7 @@ public HtmlBuilder icon(TelegramIconMode mode) {
2527
return this.space();
2628
}
2729

30+
@Override
2831
public HtmlBuilder icon(TelegramIconMode mode, int repeat) {
2932
if (mode == null) {
3033
return this;
@@ -33,48 +36,58 @@ public HtmlBuilder icon(TelegramIconMode mode, int repeat) {
3336
return this.space();
3437
}
3538

39+
@Override
3640
public HtmlBuilder timestamp(Date date, TimeZone timezone) {
3741
return this.code(Time4j.format(date, timezone));
3842
}
3943

44+
@Override
4045
public HtmlBuilder timestamp(Date date, TimeZone timezone, String format) {
4146
return this.code(Time4j.format(date, timezone, format));
4247
}
4348

49+
@Override
4450
public HtmlBuilder timestamp(Date date, TimezoneType timezone) {
4551
return this.code(Time4j.format(date, timezone));
4652
}
4753

54+
@Override
4855
public HtmlBuilder timestamp(Date date, TimezoneType timezone, String format) {
4956
return this.code(Time4j.format(date, timezone, format));
5057
}
5158

59+
@Override
5260
public HtmlBuilder timestamp(Date date, String format) {
5361
return this.code(Time4j.format(date, format));
5462
}
5563

64+
@Override
5665
public HtmlBuilder timestamp(Date date) {
5766
return this.code(Time4j.format(date, TimeFormatText.BIBLIOGRAPHY_COMPLETE_EPOCH_PATTERN));
5867
}
5968

69+
@Override
6070
public HtmlBuilder timestamp() {
6171
return this.timestamp(new Date());
6272
}
6373

74+
@Override
6475
public HtmlBuilder vertical(String text) {
6576
message.append(String4j.repeat(Ascii.Symbol.VERTICAL_LINE, 2))
6677
.append(text)
6778
.append(String4j.repeat(Ascii.Symbol.VERTICAL_LINE, 2));
6879
return this.space();
6980
}
7081

82+
@Override
7183
public HtmlBuilder vertical(Object value) {
7284
if (value == null) {
7385
return this;
7486
}
7587
return this.vertical(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
7688
}
7789

90+
@Override
7891
public HtmlBuilder bold(String text) {
7992
message.append(Ascii.Symbol.LESS_THAN_SIGN)
8093
.append(Ascii.Lowercase.LATIN_SMALL_LETTER_B)
@@ -87,6 +100,7 @@ public HtmlBuilder bold(String text) {
87100
return this.space();
88101
}
89102

103+
@Override
90104
public HtmlBuilder bold(Object value) {
91105
if (value == null) {
92106
return this;
@@ -113,6 +127,7 @@ public HtmlBuilder strong(Object value) {
113127
return this.strong(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
114128
}
115129

130+
@Override
116131
public HtmlBuilder italic(String text) {
117132
message.append(Ascii.Symbol.LESS_THAN_SIGN)
118133
.append(Ascii.Lowercase.LATIN_SMALL_LETTER_I)
@@ -125,6 +140,7 @@ public HtmlBuilder italic(String text) {
125140
return this.space();
126141
}
127142

143+
@Override
128144
public HtmlBuilder italic(Object value) {
129145
if (value == null) {
130146
return this;
@@ -151,6 +167,7 @@ public HtmlBuilder em(Object value) {
151167
return this.em(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
152168
}
153169

170+
@Override
154171
public HtmlBuilder underline(String text) {
155172
message.append(Ascii.Symbol.LESS_THAN_SIGN)
156173
.append(Ascii.Lowercase.LATIN_SMALL_LETTER_U)
@@ -163,6 +180,7 @@ public HtmlBuilder underline(String text) {
163180
return this.space();
164181
}
165182

183+
@Override
166184
public HtmlBuilder underline(Object value) {
167185
if (value == null) {
168186
return this;
@@ -189,6 +207,7 @@ public HtmlBuilder ins(Object value) {
189207
return this.ins(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
190208
}
191209

210+
@Override
192211
public HtmlBuilder strikethrough(String text) {
193212
message.append(Ascii.Symbol.LESS_THAN_SIGN)
194213
.append(Ascii.Lowercase.LATIN_SMALL_LETTER_S)
@@ -201,6 +220,7 @@ public HtmlBuilder strikethrough(String text) {
201220
return this.space();
202221
}
203222

223+
@Override
204224
public HtmlBuilder strikethrough(Object value) {
205225
if (value == null) {
206226
return this;
@@ -265,7 +285,8 @@ public HtmlBuilder spoiler(Object value) {
265285
return this.spoiler(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
266286
}
267287

268-
public HtmlBuilder inlineUrl(String text, String url) {
288+
@Override
289+
public HtmlBuilder link(String text, String url) {
269290
message.append(Ascii.Symbol.LESS_THAN_SIGN)
270291
.append(Ascii.Lowercase.LATIN_SMALL_LETTER_A)
271292
.append(Ascii.Punctuation.SPACE)
@@ -284,6 +305,7 @@ public HtmlBuilder inlineUrl(String text, String url) {
284305
return this.space();
285306
}
286307

308+
@Override
287309
public HtmlBuilder code(String text) {
288310
message.append(Ascii.Symbol.LESS_THAN_SIGN)
289311
.append("code")
@@ -296,13 +318,15 @@ public HtmlBuilder code(String text) {
296318
return this.space();
297319
}
298320

321+
@Override
299322
public HtmlBuilder code(Object value) {
300323
if (value == null) {
301324
return this;
302325
}
303326
return this.code(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
304327
}
305328

329+
@Override
306330
public HtmlBuilder code(Path filename) {
307331
try {
308332
String data = Os4j.readFileKeepFormat(filename);
@@ -312,6 +336,7 @@ public HtmlBuilder code(Path filename) {
312336
}
313337
}
314338

339+
@Override
315340
public HtmlBuilder preformatted(String text) {
316341
message.append(Ascii.Symbol.LESS_THAN_SIGN)
317342
.append("pre")
@@ -324,13 +349,15 @@ public HtmlBuilder preformatted(String text) {
324349
return this.space();
325350
}
326351

352+
@Override
327353
public HtmlBuilder preformatted(Object value) {
328354
if (value == null) {
329355
return this;
330356
}
331357
return this.preformatted(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
332358
}
333359

360+
@Override
334361
public HtmlBuilder preformatted(String lang, String text) {
335362
message.append(Ascii.Symbol.LESS_THAN_SIGN)
336363
.append("pre")
@@ -356,13 +383,15 @@ public HtmlBuilder preformatted(String lang, String text) {
356383
return this.space();
357384
}
358385

386+
@Override
359387
public HtmlBuilder preformatted(String lang, Object value) {
360388
if (value == null) {
361389
return this;
362390
}
363391
return this.preformatted(lang, Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
364392
}
365393

394+
@Override
366395
public HtmlBuilder preformatted(String lang, Path filename) {
367396
try {
368397
String data = Os4j.readFileKeepFormat(filename);
@@ -372,31 +401,37 @@ public HtmlBuilder preformatted(String lang, Path filename) {
372401
}
373402
}
374403

404+
@Override
375405
public HtmlBuilder text(String text) {
376406
message.append(text);
377407
return this.space();
378408
}
379409

410+
@Override
380411
public HtmlBuilder text(Object value) {
381412
if (value == null) {
382413
return this;
383414
}
384415
return this.text(Class4j.isPrimitive(value.getClass()) ? value.toString() : Json4j.toJson(value));
385416
}
386417

418+
@Override
387419
public HtmlBuilder line() {
388420
return this.text(System.lineSeparator());
389421
}
390422

423+
@Override
391424
public HtmlBuilder line(int repeat) {
392425
return this.text(String4j.repeat(System.lineSeparator(), repeat));
393426
}
394427

428+
@Override
395429
public HtmlBuilder space() {
396430
message.append(Ascii.Punctuation.SPACE);
397431
return this;
398432
}
399433

434+
@Override
400435
public HtmlBuilder space(int repeat) {
401436
message.append(String4j.repeat(Ascii.Punctuation.SPACE, repeat));
402437
return this;
@@ -407,3 +442,4 @@ public String toString() {
407442
return this.message.toString();
408443
}
409444
}
445+
// @formatter:on
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.bot4j.telegram.message;
2+
3+
public class HttpMessageBuilder {
4+
}

0 commit comments

Comments
 (0)