createPipeline(final TerminalOperation, ?> terminal
for (IntermediateOperation, ?> operation : operations) {
pipeline.intermediateOperations().add(operation);
}
-
- pipeline.terminatingOperation(terminalOperation);
+
+ pipeline.terminatingOperation(terminalOperation);
return pipeline;
}
diff --git a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film$.java b/provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film$.java
similarity index 88%
rename from provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film$.java
rename to provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film$.java
index 389820db3..a32e055bc 100644
--- a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film$.java
+++ b/provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film$.java
@@ -1,21 +1,13 @@
-package com.speedment.jpastreamer.termopoptimizer.standard.internal;
+package com.speedment.jpastreamer.termopmodifier.standard.internal.model;
import com.speedment.jpastreamer.field.ComparableField;
-import com.speedment.jpastreamer.field.ReferenceField;
import com.speedment.jpastreamer.field.ShortField;
import com.speedment.jpastreamer.field.StringField;
import java.math.BigDecimal;
import java.sql.Timestamp;
-/**
- * The generated base for entity {@link Film} representing entities of the
- * {@code film}-table in the database.
- * This file has been automatically generated by JPAStreamer.
- *
- * @author JPAStreamer
- */
-public final class Film$ {
+public class Film$ {
/**
* This Field corresponds to the {@link Film} field "length".
@@ -44,7 +36,7 @@ public final class Film$ {
Film::getReplacementCost,
false
);
-
+
/**
* This Field corresponds to the {@link Film} field "rating".
*/
diff --git a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film.java b/provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film.java
similarity index 95%
rename from provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film.java
rename to provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film.java
index b37d66b29..dfe68e0d8 100644
--- a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film.java
+++ b/provider/termopmodifier-standard/src/test/java/com/speedment/jpastreamer/termopmodifier/standard/internal/model/Film.java
@@ -1,17 +1,20 @@
-package com.speedment.jpastreamer.termopoptimizer.standard.internal;
+package com.speedment.jpastreamer.termopmodifier.standard.internal.model;
import jakarta.persistence.*;
+
import java.math.BigDecimal;
import java.sql.Timestamp;
-import java.util.HashSet;
@Entity
@Table(name = "film", schema = "sakila")
public class Film {
- public Film() {}
+ public Film() {
+ }
+
public Film(short filmId) {
this.filmId = filmId;
}
+
public Film(String description) {
this.description = description;
}
@@ -104,9 +107,13 @@ public void setRentalDuration(short rentalDuration) {
this.rentalDuration = rentalDuration;
}
- public String getRating() { return rating; }
+ public String getRating() {
+ return rating;
+ }
- public void setRating(String rating) { this.rating = rating; }
+ public void setRating(String rating) {
+ this.rating = rating;
+ }
public BigDecimal getRentalRate() {
return rentalRate;
@@ -131,6 +138,7 @@ public BigDecimal getReplacementCost() {
public void setReplacementCost(BigDecimal replacementCost) {
this.replacementCost = replacementCost;
}
+
public Timestamp getLastUpdate() {
return lastUpdate;
}
@@ -138,7 +146,7 @@ public Timestamp getLastUpdate() {
public void setLastUpdate(Timestamp lastUpdate) {
this.lastUpdate = lastUpdate;
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
diff --git a/provider/termopoptimizer-standard/pom.xml b/provider/termopoptimizer-standard/pom.xml
index d3d3d5d7d..546fecf3e 100644
--- a/provider/termopoptimizer-standard/pom.xml
+++ b/provider/termopoptimizer-standard/pom.xml
@@ -39,26 +39,7 @@
com.speedment.jpastreamer
termopoptimizer
-
-
- com.speedment.jpastreamer
- pipeline
-
-
-
- com.speedment.jpastreamer
- rootfactory
-
-
-
- com.speedment.jpastreamer
- pipeline-standard
- test
-
-
- com.speedment.jpastreamer
- field
-
+
diff --git a/provider/termopoptimizer-standard/src/main/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/StandardTerminalOperationOptimizer.java b/provider/termopoptimizer-standard/src/main/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/StandardTerminalOperationOptimizer.java
index 57cbf11b9..47d1bd897 100644
--- a/provider/termopoptimizer-standard/src/main/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/StandardTerminalOperationOptimizer.java
+++ b/provider/termopoptimizer-standard/src/main/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/StandardTerminalOperationOptimizer.java
@@ -12,96 +12,20 @@
*/
package com.speedment.jpastreamer.termopoptimizer.standard.internal;
-import static java.util.Objects.requireNonNull;
-
-import com.speedment.jpastreamer.criteria.PredicateFactory;
-import com.speedment.jpastreamer.field.predicate.SpeedmentPredicate;
import com.speedment.jpastreamer.pipeline.Pipeline;
-import com.speedment.jpastreamer.pipeline.intermediate.IntermediateOperationFactory;
-import com.speedment.jpastreamer.pipeline.terminal.TerminalOperation;
-import com.speedment.jpastreamer.pipeline.terminal.TerminalOperationFactory;
-import com.speedment.jpastreamer.pipeline.terminal.TerminalOperationType;
-import com.speedment.jpastreamer.rootfactory.RootFactory;
import com.speedment.jpastreamer.termopoptimizer.TerminalOperationOptimizer;
-import java.util.Optional;
-import java.util.ServiceLoader;
+import static java.util.Objects.requireNonNull;
final class StandardTerminalOperationOptimizer implements TerminalOperationOptimizer {
-
- private final IntermediateOperationFactory intermediateOperationFactory;
- private final TerminalOperationFactory terminalOperationFactory;
-
- public StandardTerminalOperationOptimizer() {
- this.intermediateOperationFactory = RootFactory.getOrThrow(IntermediateOperationFactory.class, ServiceLoader::load);
- this.terminalOperationFactory = RootFactory.getOrThrow(TerminalOperationFactory.class, ServiceLoader::load);
- }
@Override
public Pipeline optimize(Pipeline pipeline) {
requireNonNull(pipeline);
-
- final TerminalOperationType terminalOperationType = pipeline.terminatingOperation().type();
-
- switch (terminalOperationType) {
- case ANY_MATCH:
- return optimizeAnyMatch(pipeline);
- case NONE_MATCH:
- return optimizeNoneMatch(pipeline);
- case FIND_FIRST:
- return optimizeFindFirst(pipeline);
- case FIND_ANY:
- return optimizeFindAny(pipeline);
- default:
- return pipeline;
- }
- }
-
- private Pipeline optimizeAnyMatch(Pipeline pipeline) {
- this.getPredicate(pipeline.terminatingOperation()).ifPresent(speedmentPredicate -> {
- pipeline.intermediateOperations().add(intermediateOperationFactory.createLimit(1));
- pipeline.intermediateOperations().add(
- intermediateOperationFactory.createFilter(speedmentPredicate));
- pipeline.terminatingOperation(terminalOperationFactory.createAnyMatch(p -> true));
- });
- return pipeline;
- }
-
- private Pipeline optimizeNoneMatch(Pipeline pipeline) {
- this.getPredicate(pipeline.terminatingOperation()).ifPresent(speedmentPredicate -> {
- pipeline.intermediateOperations().add(intermediateOperationFactory.createLimit(1));
- pipeline.intermediateOperations().add(intermediateOperationFactory.createFilter(speedmentPredicate));
- // NoneMatch() - If the stream is empty then true is returned and the predicate is not evaluated.
- // If the expression is evaluated => There is a match and the expression is always false.
- pipeline.terminatingOperation(terminalOperationFactory.createNoneMatch(e -> false));
- });
- return pipeline;
- }
-
- private Pipeline optimizeFindFirst(Pipeline pipeline) {
- pipeline.intermediateOperations().add(intermediateOperationFactory.createLimit(1));
- return pipeline;
- }
-
- private Pipeline optimizeFindAny(Pipeline pipeline) {
- pipeline.ordered(false);
- pipeline.intermediateOperations().add(intermediateOperationFactory.createLimit(1));
+ // For now, just return whatever we get.
+
return pipeline;
}
-
- private Optional> getPredicate(final TerminalOperation, ?> operation) {
- final Object[] arguments = operation.arguments();
-
- if (arguments.length != 1) {
- return Optional.empty();
- }
-
- if (arguments[0] instanceof SpeedmentPredicate) {
- return Optional.of((SpeedmentPredicate) arguments[0]);
- }
-
- return Optional.empty();
- }
}
diff --git a/provider/termopoptimizer-standard/src/main/java9/module-info.java b/provider/termopoptimizer-standard/src/main/java9/module-info.java
index 169c0eb0f..46961365a 100644
--- a/provider/termopoptimizer-standard/src/main/java9/module-info.java
+++ b/provider/termopoptimizer-standard/src/main/java9/module-info.java
@@ -12,8 +12,6 @@
*/
module jpastreamer.termopoptimizer.standard {
requires transitive jpastreamer.termopoptimizer;
- requires jpastreamer.rootfactory;
- requires jpastreamer.predicate;
exports com.speedment.jpastreamer.termopoptimizer.standard;
diff --git a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/StandardTerminalOperationOptimizerFactoryTest.java b/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/StandardTerminalOperationOptimizerFactoryTest.java
deleted file mode 100644
index 85c1d5cc6..000000000
--- a/provider/termopoptimizer-standard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/StandardTerminalOperationOptimizerFactoryTest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.speedment.jpastreamer.termopoptimizer.standard;
-
-import com.speedment.jpastreamer.termopoptimizer.TerminalOperationOptimizerFactory;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-final class StandardTerminalOperationOptimizerFactoryTest {
-
- @Test
- void get() {
- final TerminalOperationOptimizerFactory terminalOperationOptimizerFactory = new StandardTerminalOperationOptimizerFactory();
- assertNotNull(terminalOperationOptimizerFactory.get());
- }
-
-}