diff --git a/jOOQ/src/main/java/org/jooq/QueryPart.java b/jOOQ/src/main/java/org/jooq/QueryPart.java index 663dbe1f97..bfe716900a 100644 --- a/jOOQ/src/main/java/org/jooq/QueryPart.java +++ b/jOOQ/src/main/java/org/jooq/QueryPart.java @@ -39,12 +39,11 @@ package org.jooq; import java.io.Serializable; import java.util.function.BiFunction; -import java.util.function.Predicate; +import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Collector; import org.jooq.conf.Settings; -import org.jooq.impl.Internal; -import org.jooq.impl.QOM.NotYetImplementedException; import org.jetbrains.annotations.NotNull; @@ -108,81 +107,89 @@ public interface QueryPart extends Serializable { @Override int hashCode(); - // ------------------------------------------------------------------------- - // XXX: Query Object Model - // ------------------------------------------------------------------------- - /** - * Traverser this {@link QueryPart} expression tree using a composable - * {@link Traverser}, producing a result. - *
- * This offers a generic way to traverse expression trees to translate the - * tree to arbitrary other data structures. The simplest traversal would - * just count all the tree elements: - *
- *
- *
- * int count = CUSTOMER.NAME.eq(1).$traverse(0, (i, p) -> i + 1);
- *
- * The same can be achieved by translating the JDK {@link Collector} API to - * the {@link Traverser} API using {@link Traversers#collecting(Collector)}. - *
- *
- *
- * CUSTOMER.NAME.eq(1).$traverse(Traversers.collecting(Collectors.counting()));
- *
- * Unlike a {@link Collector}, a {@link Traverser} is optimised for tree - * traversal, not stream traversal: - *
- * This is a commercial jOOQ edition only feature.
- */
- default
- * This is a commercial jOOQ edition only feature.
- *
- * @param recurse A predicate to decide whether to recurse into a
- * {@link QueryPart} subtree.
- * @param replacement The replacement function. Replacement continues
- * recursively until the function returns null or its input for
- * any given input.
- */
- @NotNull
- default QueryPart $replace(
- Predicate super QueryPart> recurse,
- Function1 super QueryPart, ? extends QueryPart> replacement
- ) {
- Internal.requireCommercial(() -> "Query object model traversal is available in the commercial jOOQ distribution only. Please consider upgrading to the jOOQ Professional Edition or jOOQ Enterprise Edition.");
- throw new NotYetImplementedException();
- }
- /**
- * Convenience method for {@link #$replace(Predicate, Function1)}.
- */
- @NotNull
- default QueryPart $replace(Function1 super QueryPart, ? extends QueryPart> replacement) {
- return $replace(p -> true, replacement);
- }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
diff --git a/jOOQ/src/main/java/org/jooq/Replacer.java b/jOOQ/src/main/java/org/jooq/Replacer.java
new file mode 100644
index 0000000000..90e1e4f4d7
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/Replacer.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jOOQ/src/main/java/org/jooq/Traverser.java b/jOOQ/src/main/java/org/jooq/Traverser.java
index d9325be8cf..87a2806173 100644
--- a/jOOQ/src/main/java/org/jooq/Traverser.java
+++ b/jOOQ/src/main/java/org/jooq/Traverser.java
@@ -37,164 +37,172 @@
*/
package org.jooq;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.stream.Collector;
-import java.util.stream.Stream;
-/**
- * An API for {@link QueryPart#$traverse(Traverser)} query part traversals.
- *
- * Similar to a {@link Collector} for {@link Stream#collect(Collector)}, this
- * type wraps:
- *
- *
- *
- */
-public interface Traverser {
- /**
- * Convenience method to create a {@link Traverser} with a
- * {@link #supplier()} and {@link #before()}.
- */
- static