You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/10/17 05:36:15 UTC

[isis] 01/02: ISIS-2007: uses Objects.requireNonNull(Object, Supplier) in all cases... actually just 3

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

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

commit 72765aa9413389ac338a88a97f6f79bc50dfd84a
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 17 06:16:47 2018 +0200

    ISIS-2007: uses Objects.requireNonNull(Object, Supplier<String>) in all cases... actually just 3
---
 .../persistence/PersistenceSessionFactory4.java    |  3 ++-
 .../persistence/PersistenceSessionFactory5.java    |  3 ++-
 .../factories/OidFactory_Builder.java              | 31 +++++++++-------------
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory4.java b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory4.java
index 5e6e6e3..f7e5109 100644
--- a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory4.java
+++ b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory4.java
@@ -188,7 +188,8 @@ PersistenceSessionFactory, ApplicationScopedComponent, FixturesInstalledFlag {
             final ServicesInjector servicesInjector,
             final AuthenticationSession authenticationSession) {
 
-        Objects.requireNonNull(applicationComponents, "PersistenceSession5 requires initialization. "+this.hashCode());
+        Objects.requireNonNull(applicationComponents,
+                () -> "PersistenceSession5 requires initialization. " + this.hashCode());
         
         final FixturesInstalledFlag fixturesInstalledFlag = this;
         
diff --git a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory5.java b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory5.java
index 12014b4..a08f3d3 100644
--- a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory5.java
+++ b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory5.java
@@ -188,7 +188,8 @@ implements PersistenceSessionFactory, ApplicationScopedComponent, FixturesInstal
             final ServicesInjector servicesInjector,
             final AuthenticationSession authenticationSession) {
 
-        Objects.requireNonNull(applicationComponents.get(), "PersistenceSession5 requires initialization. "+this.hashCode());
+        Objects.requireNonNull(applicationComponents.get(),
+                () -> "PersistenceSession5 requires initialization. "+this.hashCode());
         
         final FixturesInstalledFlag fixturesInstalledFlag = this;
         
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/factories/OidFactory_Builder.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/factories/OidFactory_Builder.java
index bda33ab..4f4e46a 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/factories/OidFactory_Builder.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/factories/OidFactory_Builder.java
@@ -46,24 +46,19 @@ class OidFactory_Builder implements OidFactoryBuilder {
 
     @Override
     public OidFactory build() {
-        return new OidFactory() {
-            
-            @Override
-            public RootOid oidFor(Object pojo) {
-                
-                final ObjectSpecification spec = specProvider.apply(pojo);
-                
-                final RootOid rootOid = handler.stream()
-                .filter(h->h.isHandling(pojo, spec))
-                .findFirst()
-                .map(h->h.oidFor(pojo, spec))
-                .orElse(null);
-                
-                Objects.requireNonNull(rootOid, "Could not create an Oid for pojo: "+pojo);
-                
-                return rootOid;
-            }
-            
+        return pojo -> {
+
+            final ObjectSpecification spec = specProvider.apply(pojo);
+
+            final RootOid rootOid = handler.stream()
+            .filter(h->h.isHandling(pojo, spec))
+            .findFirst()
+            .map(h->h.oidFor(pojo, spec))
+            .orElse(null);
+
+            Objects.requireNonNull(rootOid, () -> "Could not create an Oid for pojo: "+pojo);
+
+            return rootOid;
         };
     }