Skip to content

Commit

Permalink
♻️ refactor: refactor codebase #3
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Sep 21, 2024
1 parent f776210 commit 8b19370
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions plugin/src/main/groovy/org/unify4j/common/Text4j.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ public Text4j append(String str) {
return this.space();
}

/**
* Appends a non-empty string to the message.
*
* @param str The string to append.
* @return The current instance of Text4j.
*/
public Text4j appendSkippedSpace(String str) {
if (String4j.isNotEmpty(str)) {
message.append(str);
}
return this;
}

/**
* Appends a string repeated a specified number of times followed by a space.
*
Expand All @@ -51,6 +64,19 @@ public Text4j append(Object o) {
return this;
}

/**
* Appends a non-null object's string representation (or its JSON if not a primitive).
*
* @param o The object to append.
* @return The current instance of Text4j.
*/
public Text4j appendSkippedSpace(Object o) {
if (o != null) {
return this.appendSkippedSpace(Class4j.isPrimitive(o.getClass()) ? o.toString() : Json4j.toJson(o));
}
return this;
}

/**
* Appends a non-null object's string representation (or its JSON if not a primitive) repeated a specified number of times.
*
Expand Down

0 comments on commit 8b19370

Please sign in to comment.