You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/08/30 17:47:50 UTC

(commons-text) 02/02: Use Objects.toString()

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit b55435665f8c4a051f1407118bfa17ed176793b2
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 30 13:41:15 2025 -0400

    Use Objects.toString()
---
 .../java/org/apache/commons/text/TextStringBuilder.java     | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index dcf816f9..a7db693c 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -2322,16 +2322,13 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      * Inserts the string representation of an object into this builder. Inserting null will use the stored null text
      * value.
      *
-     * @param index the index to add at, must be valid
-     * @param obj the object to insert
-     * @return this, to enable chaining
-     * @throws IndexOutOfBoundsException if the index is invalid
+     * @param index the index to add at, must be valid.
+     * @param obj the object to insert.
+     * @return this, to enable chaining.
+     * @throws IndexOutOfBoundsException if the index is invalid.
      */
     public TextStringBuilder insert(final int index, final Object obj) {
-        if (obj == null) {
-            return insert(index, nullText);
-        }
-        return insert(index, obj.toString());
+        return insert(index, Objects.toString(obj, nullText));
     }
 
     /**