camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lburgazz...@apache.org
Subject [2/2] camel git commit: ComponentExtension : allow to unwrap to concrete extension.
Date Thu, 24 Aug 2017 14:08:34 GMT
ComponentExtension : allow to unwrap to concrete extension.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4da9afdb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4da9afdb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4da9afdb

Branch: refs/heads/master
Commit: 4da9afdb8adb7163131c0aba3d8d2d2f8e9342e0
Parents: 60d0ed8
Author: lburgazzoli <lburgazzoli@gmail.com>
Authored: Thu Aug 24 16:06:00 2017 +0200
Committer: lburgazzoli <lburgazzoli@gmail.com>
Committed: Thu Aug 24 16:08:23 2017 +0200

----------------------------------------------------------------------
 .../component/extension/ComponentExtension.java     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4da9afdb/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
index 8d90d31..fca2371 100644
--- a/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
+++ b/camel-core/src/main/java/org/apache/camel/component/extension/ComponentExtension.java
@@ -23,4 +23,20 @@ package org.apache.camel.component.extension;
  * ServiceMetaData.
  */
 public interface ComponentExtension {
+    /**
+     * Access the underlying concrete ComponentExtension implementation to
+     * provide access to further features.
+     *
+     * @param clazz the proprietary class or interface of the underlying concrete ComponentExtension.
+     * @return an instance of the underlying concrete ComponentExtension as the required
type.
+     */
+    default <T extends ComponentExtension> T unwrap(Class<T> clazz) {
+        if (ComponentExtension.class.isAssignableFrom(clazz)) {
+            return clazz.cast(this);
+        }
+
+        throw new IllegalArgumentException(
+            "Unable to unwrap this ComponentExtension type (" + getClass() + ") to the required
type (" + clazz + ")"
+        );
+    }
 }


Mime
View raw message