You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/01/23 10:22:51 UTC

[isis] branch master updated: ISIS-2492: consider the corner case, that the action's type (prototyping or not) can be overriden when inherited

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e962f96  ISIS-2492: consider the corner case, that the action's type (prototyping or not) can be overriden when inherited
e962f96 is described below

commit e962f967550bd795d0fc9aa24aaf1dd5daee0447
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Jan 23 11:22:31 2021 +0100

    ISIS-2492: consider the corner case, that the action's type (prototyping
    or
    not) can be overriden when inherited
---
 .../specimpl/dflt/ObjectSpecificationDefault.java      | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
index 5aed2d6..dc61194 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
@@ -26,6 +26,8 @@ import java.util.Optional;
 import java.util.function.BiConsumer;
 import java.util.stream.Stream;
 
+import javax.annotation.Nullable;
+
 import org.apache.isis.applib.Identifier;
 import org.apache.isis.applib.services.metamodel.BeanSort;
 import org.apache.isis.commons.collections.ImmutableEnumSet;
@@ -271,18 +273,28 @@ implements FacetHolder {
     // -- findObjectAction
     
     @Override
-    public Optional<ObjectAction> findObjectAction(String id, ActionType type) {
+    public Optional<ObjectAction> findObjectAction(String id, @Nullable ActionType type) {
 
         if(isTypeHierarchyRoot()) {
-            return Optional.empty();
+            return Optional.empty(); // stop search as we reached the Object class, which does not contribute actions 
         }
         
-        val declaredAction = getObjectAction(id, type); // no inheritance considered
+        val declaredAction = getObjectAction(id); // no inheritance nor type considered
                 
         if(declaredAction.isPresent()) {
+            // action found but if its not the right type, stop searching
+            if(type!=null
+                    && declaredAction.get().getType() != type) {
+                return Optional.empty();
+            }
             return declaredAction; 
         }
         
+        if(superclass()==null) {
+            // guard against unexpected reach of type hierarchy root
+            return Optional.empty();
+        }
+        
         return superclass().findObjectAction(id, type);
         
         //XXX future extensions should also search the interfaces,