File tree Expand file tree Collapse file tree
application/src/main/java/org/togetherjava/tjbot/features/basic Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1-
21package 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+ */
410public 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 }
You can’t perform that action at this time.
0 commit comments