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 2020/01/16 14:33:56 UTC
[isis] branch master updated: ISIS-2265: HomePageActionContainer:
attempting to improve code quality
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 95b2aa1 ISIS-2265: HomePageActionContainer: attempting to improve code quality
95b2aa1 is described below
commit 95b2aa16f300fffff64eafb2b981e58bb82a9f12
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jan 16 15:33:46 2020 +0100
ISIS-2265: HomePageActionContainer: attempting to improve code quality
---
.../homepage/HomePageResolverServiceDefault.java | 34 ++++++++++++----------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/homepage/HomePageResolverServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/homepage/HomePageResolverServiceDefault.java
index e9e3933..b67daba 100644
--- a/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/homepage/HomePageResolverServiceDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/isis/core/runtimeservices/homepage/HomePageResolverServiceDefault.java
@@ -18,6 +18,8 @@
*/
package org.apache.isis.core.runtimeservices.homepage;
+import java.util.function.BiFunction;
+
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Named;
@@ -138,18 +140,24 @@ public class HomePageResolverServiceDefault implements HomePageResolverService {
return viewModelPojo;
}
- // lookup my 'homePage' method as action object
- private static ObjectAction homePageMethodAsAction(
+ // lookup my 'homePage' method as action object
+ // if usable as HomePageAction, then
+ // programmatically make the MM aware of the 'homePage' action to be used as THE App's home-page action
+ private static HomePageAction homePageActionIfUsable(
Class<?> viewModelType,
- ObjectSpecification spec) {
+ SpecificationLoader specLoader,
+ BiFunction<ObjectAction, ObjectSpecification, HomePageAction> toHomePageActionIfUsable) {
- HomePageActionContainer.viewModelType = viewModelType;
- val homePageMethodAsAction = spec.streamObjectActions(Contributed.EXCLUDED)
+ val mySpec = specLoader.loadSpecification(HomePageActionContainer.class);
+ val homePageMethodAsAction = mySpec.streamObjectActions(Contributed.EXCLUDED)
.filter(objectAction->objectAction.getId().equals("homePage"))
.peek(objectAction->objectAction.addFacet(new HomePageFacetImpl(objectAction)))
.findAny()
.orElseThrow(_Exceptions::unexpectedCodeReach);
- return homePageMethodAsAction;
+
+ HomePageActionContainer.viewModelType = viewModelType;
+
+ return toHomePageActionIfUsable.apply(homePageMethodAsAction, mySpec);
}
}
@@ -164,19 +172,15 @@ public class HomePageResolverServiceDefault implements HomePageResolverService {
return null;
}
- val containerSpec = specLoader.loadSpecification(HomePageActionContainer.class);
- val homePageMethodAsAction = HomePageActionContainer.homePageMethodAsAction(type, containerSpec);
-
- // if usable
- // programmatically make the MM aware of the 'homePage' action to be used as THE home-page action
- val homePageActionIfUsable = homePageActionIfUsable(homePageMethodAsAction, containerSpec);
+ val homePageAction = HomePageActionContainer.homePageActionIfUsable(
+ type, specLoader, this::homePageActionIfUsable);
- return homePageActionIfUsable;
+ return homePageAction;
}
protected HomePageAction homePageActionIfUsable(
- @Nullable ObjectAction objectAction,
- ObjectSpecification spec) {
+ final @Nullable ObjectAction objectAction,
+ final ObjectSpecification spec) {
if (objectAction==null || !objectAction.containsNonFallbackFacet(HomePageFacet.class)) {
return null;