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 f4523fa413bd2c19ad8f0401ab8858c478d16a85
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Mon Jan 26 11:04:59 2026 +0000

    (chores): modernize instanceof checks in camel-webhook
---
 .../camel/component/webhook/WebhookRoutePolicy.java      |  3 +--
 .../org/apache/camel/component/webhook/WebhookUtils.java | 16 ++++++++--------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git 
a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
 
b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
index 1e489365feb9..696a7d4b9877 100644
--- 
a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
+++ 
b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookRoutePolicy.java
@@ -35,8 +35,7 @@ class WebhookRoutePolicy extends RoutePolicySupport {
         super.onInit(route);
         route.setAutoStartup(false);
 
-        if (route.getEndpoint() instanceof WebhookEndpoint) {
-            WebhookEndpoint webhook = (WebhookEndpoint) route.getEndpoint();
+        if (route.getEndpoint() instanceof WebhookEndpoint webhook) {
             if (webhook.getConfiguration() != null && 
webhook.getConfiguration().isWebhookAutoRegister()) {
                 throw new IllegalStateException(
                         "Webhook auto-register is enabled on endpoint " + 
webhook
diff --git 
a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
 
b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
index ec4701d5d910..ad30b424e8a0 100644
--- 
a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
+++ 
b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookUtils.java
@@ -41,12 +41,12 @@ public final class WebhookUtils {
         RestConsumerFactory factory = null;
         if (configuration.getWebhookComponentName() != null) {
             Object comp = 
context.getRegistry().lookupByName(configuration.getWebhookComponentName());
-            if (comp instanceof RestConsumerFactory) {
-                factory = (RestConsumerFactory) comp;
+            if (comp instanceof RestConsumerFactory restconsumerfactory4) {
+                factory = restconsumerfactory4;
             } else {
                 comp = 
context.getComponent(configuration.getWebhookComponentName());
-                if (comp instanceof RestConsumerFactory) {
-                    factory = (RestConsumerFactory) comp;
+                if (comp instanceof RestConsumerFactory restconsumerfactory3) {
+                    factory = restconsumerfactory3;
                 }
             }
 
@@ -64,8 +64,8 @@ public final class WebhookUtils {
         if (factory == null) {
             for (String name : context.getComponentNames()) {
                 Component comp = context.getComponent(name);
-                if (comp instanceof RestConsumerFactory) {
-                    factory = (RestConsumerFactory) comp;
+                if (comp instanceof RestConsumerFactory restconsumerfactory2) {
+                    factory = restconsumerfactory2;
                     break;
                 }
             }
@@ -85,9 +85,9 @@ public final class WebhookUtils {
             RestConsumerFactory found = null;
             for (String name : DEFAULT_REST_CONSUMER_COMPONENTS) {
                 Object comp = context.getComponent(name, true);
-                if (comp instanceof RestConsumerFactory) {
+                if (comp instanceof RestConsumerFactory restconsumerfactory) {
                     if (found == null) {
-                        found = (RestConsumerFactory) comp;
+                        found = restconsumerfactory;
                     } else {
                         throw new IllegalArgumentException(
                                 "Multiple RestConsumerFactory found on 
classpath. Configure explicit which component to use");

Reply via email to