Skip to content

Commit 6b6b883

Browse files
committed
docs(ThreadTitle): add JavaDocs and rename param
Addresses code review by @christolis. Co-authorized-by: Chris Sdogkos <work@chris-sdogkos.com> Signed-off-by: Chris Sdogkos <work@chris-sdogkos.com> Signed-off-by: billpapat <50835814+billpapat@users.noreply.github.com>
1 parent 08da794 commit 6b6b883

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

application/src/main/java/org/togetherjava/tjbot/features/basic/ThreadTitle.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
21
package org.togetherjava.tjbot.features.basic;
32

3+
/**
4+
* Represents a thread title, enforcing a maximum length of 60 characters. If an initial title
5+
* exceeds this limit, it's truncated at the last word boundary before or at the 60-character mark
6+
* to prevent cutting words mid-sentence. If no space is found, it truncates at 60 characters.
7+
* Provides a static factory method `withFallback` to create a ThreadTitle, using a fallback title
8+
* if the primary title is empty.
9+
*/
410
public record ThreadTitle(String value) {
511

612
private static final int TITLE_MAX_LENGTH = 60;
@@ -22,9 +28,9 @@ public ThreadTitle(String value) {
2228
this.value = threadTitle;
2329
}
2430

25-
public static ThreadTitle withFallback(String threadtitle, String fallback) {
26-
if (!threadtitle.isEmpty()) {
27-
return new ThreadTitle(threadtitle);
31+
public static ThreadTitle withFallback(String primary, String fallback) {
32+
if (!primary.isEmpty()) {
33+
return new ThreadTitle(primary);
2834
} else {
2935
return new ThreadTitle(fallback);
3036
}

0 commit comments

Comments
 (0)