cleaned up processing
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/UpdateBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/UpdateBuilder.java
index 5fe8463..c0ffd77 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/UpdateBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/UpdateBuilder.java
@@ -123,8 +123,8 @@
}
/**
- * Checks that deletes or inserts have been added to the builder.
- * @return true if there are any delete or insert statements.
+ * Checks that no deletes or inserts have been added to the builder.
+ * @return true if there are no delete or insert statements.
*/
public boolean isEmpty() {
return deletes.isEmpty() && inserts.isEmpty();
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/DatasetHandler.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/DatasetHandler.java
index 26ce281..c47c931 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/DatasetHandler.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/DatasetHandler.java
@@ -17,9 +17,9 @@
*/
package org.apache.jena.arq.querybuilder.handlers;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.function.Consumer;
import org.apache.jena.graph.FrontsNode;
import org.apache.jena.graph.Node;
@@ -80,39 +80,49 @@
}
/**
- * Add a graph name to the from named list.
+ * Add one or more named graphs to the query.
+ * if {@code graphName} is a {@code collection} or an array each element in the
+ * @code collection} or array is converted to a string and the result added to the
+ * query.
*
- * @param graphName The graph name to add.
+ * @param graphName the name to add.
+ * @see #asGraphName(Object)
*/
public void fromNamed(Object graphName) {
- if (graphName instanceof Collection) {
- ((Collection<?>)graphName).forEach(this::fromNamed);
- } else if (graphName instanceof Object[]) {
- for (Object o : ((Object[])graphName)) {
- fromNamed(o);
- }
- } else {
- query.addNamedGraphURI(asGraphName(graphName));
- }
+ processGraphName(query::addNamedGraphURI, graphName);
}
/**
- * Add the graph names to the from list.
- *
- * @param graphName the name to add.
+ * Converts performs a single level of unwrapping an Iterable before calling
+ * the {@code process} method with the graph name converted to a string.
+ * @param process the process that accepts the string graph name.
+ * @param graphName the Object that represents one or more graph names.
+ * @see #asGraphName(Object)
*/
- public void from(Object graphName) {
- if (graphName instanceof Collection) {
- ((Collection<?>)graphName).forEach(this::from);
- } else if (graphName instanceof Object[]) {
- for (Object o : ((Object[])graphName)) {
- from(o);
+ private void processGraphName(Consumer<String> process, Object graphName) {
+ if (graphName instanceof Iterable collection) {
+ for (Object o : collection) {
+ process.accept(asGraphName(o));
}
} else {
- query.addGraphURI(asGraphName(graphName));
+ process.accept(asGraphName(graphName));
}
}
+
+ /**
+ * Add one or more graph names to the query.
+ * if {@code graphName} is a {@code collection} or an array each element in the
+ * @code collection} or array is converted to a string and the result added to the
+ * query.
+ *
+ * @param graphName the name to add.
+ * @see #asGraphName(Object)
+ */
+ public void from(Object graphName) {
+ processGraphName(query::addGraphURI, graphName);
+ }
+
/**
* Set the variables for field names that contain lists of strings.
*