afs commented on code in PR #2359:
URL: https://github.com/apache/jena/pull/2359#discussion_r1530611989


##########
jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/DatasetHandler.java:
##########
@@ -54,24 +57,42 @@ public void addAll(DatasetHandler datasetHandler) {
     }
 
     /**
-     * Add a graph name to the from named list.
-     *
-     * @param graphName The graph name to add.
+     * Converts an object into a graph name.
+     * @param graphName the object that represents the graph name.
+     * @return the string that is the graph name.
      */
-    public void fromNamed(String graphName) {
-        query.addNamedGraphURI(graphName);
+    String asGraphName(Object graphName) {
+        // package private for testing access
+        if (graphName instanceof String) {
+            return (String) graphName;
+        }
+        if (graphName instanceof FrontsNode) {
+            return asGraphName(((FrontsNode)graphName).asNode());
+        }
+        if (graphName instanceof Node_URI) {
+            return ((Node_URI)graphName).getURI();
+        }
+        if (graphName instanceof Node_Literal) {
+            return asGraphName(((Node_Literal)graphName).getLiteralValue());
+        }
+
+        return graphName.toString();
     }
 
     /**
-     * Add the graph names to the from named list.
-     *
-     * The names are ordered in as defined in the collection.
+     * Add a graph name to the from named list.
      *
-     * @param graphNames The from names to add.
+     * @param graphName The graph name to add.
      */
-    public void fromNamed(Collection<String> graphNames) {
-        for (String uri : graphNames) {
-            query.addNamedGraphURI(uri);
+    public void fromNamed(Object graphName) {
+        if (graphName instanceof Collection) {

Review Comment:
   Could be a java17 
   
   ```
   if (graphName instanceof Collection collection) {
      collection.forEach(this:fromNamed);
   }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to