You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2022/06/13 00:46:21 UTC

[GitHub] [jena] Aklakan commented on a diff in pull request #1375: GH-1374: add copying Context helper method and new QueryExcecution factory method

Aklakan commented on code in PR #1375:
URL: https://github.com/apache/jena/pull/1375#discussion_r895257601


##########
jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropertyFunctionRegistry.java:
##########
@@ -77,7 +78,20 @@ public synchronized static PropertyFunctionRegistry get()
         }
         return reg ;
     }
-    
+
+    /**
+     * Copies the origin registry into a new one, or makes a fresh instance if the specified registry is {@code null).
+     * @param from {@link PropertyFunctionRegistry} or {@code null}
+     * @return {@code PropertyFunctionRegistry} a new instance
+     */
+    public static PropertyFunctionRegistry createFrom(PropertyFunctionRegistry from) {
+        PropertyFunctionRegistry res = new PropertyFunctionRegistry();
+        if (from == null) {
+            return res;
+        }
+        res.registry.putAll(from.registry);
+        return res;

Review Comment:
   Redundant return can be removed if written that way:
   ```
           if (from != null) {
               res.registry.putAll(from.registry);
           }
           return res;
   ```



##########
jena-arq/src/main/java/org/apache/jena/sparql/pfunction/PropertyFunctionRegistry.java:
##########
@@ -77,7 +78,20 @@ public synchronized static PropertyFunctionRegistry get()
         }
         return reg ;
     }
-    
+
+    /**
+     * Copies the origin registry into a new one, or makes a fresh instance if the specified registry is {@code null).
+     * @param from {@link PropertyFunctionRegistry} or {@code null}
+     * @return {@code PropertyFunctionRegistry} a new instance
+     */
+    public static PropertyFunctionRegistry createFrom(PropertyFunctionRegistry from) {
+        PropertyFunctionRegistry res = new PropertyFunctionRegistry();
+        if (from == null) {
+            return res;
+        }
+        res.registry.putAll(from.registry);
+        return res;

Review Comment:
   Redundant return can be removed if written that way:
   ```java
           if (from != null) {
               res.registry.putAll(from.registry);
           }
           return res;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org