Skip to content

Commit b554356

Browse files
committed
Use Objects.toString()
1 parent 125a97f commit b554356

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/main/java/org/apache/commons/text/TextStringBuilder.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,16 +2322,13 @@ public TextStringBuilder insert(final int index, final long value) {
23222322
* Inserts the string representation of an object into this builder. Inserting null will use the stored null text
23232323
* value.
23242324
*
2325-
* @param index the index to add at, must be valid
2326-
* @param obj the object to insert
2327-
* @return this, to enable chaining
2328-
* @throws IndexOutOfBoundsException if the index is invalid
2325+
* @param index the index to add at, must be valid.
2326+
* @param obj the object to insert.
2327+
* @return this, to enable chaining.
2328+
* @throws IndexOutOfBoundsException if the index is invalid.
23292329
*/
23302330
public TextStringBuilder insert(final int index, final Object obj) {
2331-
if (obj == null) {
2332-
return insert(index, nullText);
2333-
}
2334-
return insert(index, obj.toString());
2331+
return insert(index, Objects.toString(obj, nullText));
23352332
}
23362333

23372334
/**

0 commit comments

Comments
 (0)