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

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 469a1fa8f426323f99aef2077e145a4ecd565a2b
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Tue May 14 11:14:04 2024 +0200

    Use enhanced for loops and instanceof pattern matching
---
 .../org/apache/camel/processor/RecipientListProcessor.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
index c12ea0b4873..c948c091208 100644
--- 
a/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
+++ 
b/core/camel-core-processor/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
@@ -200,18 +200,15 @@ public class RecipientListProcessor extends 
MulticastProcessor {
 
         // optimize for recipient without need for using delimiter
         // (if its list/collection/array type)
-        if (recipientList instanceof List) {
-            List<?> col = (List<?>) recipientList;
+        if (recipientList instanceof List<?> col) {
             int size = col.size();
             List<ProcessorExchangePair> result = new ArrayList<>(size);
             int index = 0;
-            for (int i = 0; i < size; i++) {
-                Object recipient = col.get(i);
+            for (Object recipient : col) {
                 index = doCreateProcessorExchangePairs(exchange, recipient, 
result, index);
             }
             return result;
-        } else if (recipientList instanceof Collection) {
-            Collection<?> col = (Collection<?>) recipientList;
+        } else if (recipientList instanceof Collection<?> col) {
             int size = col.size();
             List<ProcessorExchangePair> result = new ArrayList<>(size);
             int index = 0;
@@ -224,8 +221,7 @@ public class RecipientListProcessor extends 
MulticastProcessor {
             int size = Array.getLength(recipientList);
             List<ProcessorExchangePair> result = new ArrayList<>(size);
             int index = 0;
-            for (int i = 0; i < size; i++) {
-                Object recipient = arr[i];
+            for (Object recipient : arr) {
                 index = doCreateProcessorExchangePairs(exchange, recipient, 
result, index);
             }
             return result;

Reply via email to