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

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

commit 061d5ce6290b60fdec9f88b3c55491fec1b1acbc
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Jan 26 11:50:26 2026 +0000

    (chores): modernize instanceof checks in camel-attachments
---
 .../java/org/apache/camel/attachment/DefaultAttachment.java  | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
 
b/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
index b95d694e6aff..88e68aa2be62 100644
--- 
a/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
+++ 
b/components/camel-attachments/src/main/java/org/apache/camel/attachment/DefaultAttachment.java
@@ -49,8 +49,8 @@ public class DefaultAttachment implements Attachment {
     public String getHeader(String name) {
         if (headers != null) {
             Object headerObject = headers.get(name);
-            if (headerObject instanceof String) {
-                return (String) headerObject;
+            if (headerObject instanceof String str) {
+                return str;
             } else if (headerObject instanceof Collection<?>) {
                 return 
CollectionHelper.collectionAsCommaDelimitedString((Collection<?>) headerObject);
             }
@@ -65,8 +65,8 @@ public class DefaultAttachment implements Attachment {
             Object headerObject = headers.get(name);
             if (headerObject instanceof List<?>) {
                 return (List<String>) headerObject;
-            } else if (headerObject instanceof String) {
-                return Collections.singletonList((String) headerObject);
+            } else if (headerObject instanceof String str) {
+                return Collections.singletonList(str);
             }
         }
         return null;
@@ -113,8 +113,8 @@ public class DefaultAttachment implements Attachment {
 
     @Override
     public boolean equals(Object other) {
-        if (other instanceof Attachment) {
-            DataHandler otherDh = ((Attachment) other).getDataHandler();
+        if (other instanceof Attachment attachment) {
+            DataHandler otherDh = attachment.getDataHandler();
             return dataHandler.equals(otherDh);
         }
         return false;

Reply via email to