You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/02/24 16:52:43 UTC

[jspwiki] 01/38: JSPWIKI-120: add adapt( Class< E > cls ) method to Engine

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

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 52d21f1d4efd8931589399a7feba7e76ad63441e
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 19 14:23:52 2020 +0100

    JSPWIKI-120: add adapt( Class< E > cls ) method to Engine
---
 .../src/main/java/org/apache/wiki/api/core/Engine.java        | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
index 7cb1bf6..cc45798 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
@@ -82,6 +82,17 @@ public interface Engine {
     String PROP_ALLOW_CREATION_OF_EMPTY_PAGES = "jspwiki.allowCreationOfEmptyPages";
 
     /**
+     * Adapt Engine to a concrete type.
+     *
+     * @param cls class denoting the type to adapt to.
+     * @param <E> type to adapt to.
+     * @return engine instance adapted to the requested type. Might throw an unchecked exception if the instance cannot be adapted to requested type!
+     */
+    default < E extends Engine > E adapt( Class< E > cls ) {
+        return ( E )this;
+    }
+
+    /**
      * Retrieves the requested object instantiated by the Engine.
      *
      * @param manager requested object instantiated by the Engine.