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 2022/07/07 12:30:06 UTC

[commons-text] 02/03: Use forEach APIs

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 f96a5ce27a8dbb63394c20b53888e85a1a018152
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jul 7 08:07:16 2022 -0400

    Use forEach APIs
---
 src/main/java/org/apache/commons/text/TextStringBuilder.java | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index 296c2262..913d8984 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -781,9 +781,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      */
     public TextStringBuilder appendAll(final Iterable<?> iterable) {
         if (iterable != null) {
-            for (final Object o : iterable) {
-                append(o);
-            }
+            iterable.forEach(this::append);
         }
         return this;
     }
@@ -797,9 +795,7 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
      */
     public TextStringBuilder appendAll(final Iterator<?> it) {
         if (it != null) {
-            while (it.hasNext()) {
-                append(it.next());
-            }
+            it.forEachRemaining(this::append);
         }
         return this;
     }