diff --git a/spock-core/src/main/java/org/spockframework/runtime/SpecProcessor.java b/spock-core/src/main/java/org/spockframework/runtime/SpecProcessor.java new file mode 100644 index 0000000000..b575c857ed --- /dev/null +++ b/spock-core/src/main/java/org/spockframework/runtime/SpecProcessor.java @@ -0,0 +1,9 @@ +package org.spockframework.runtime; + +import org.spockframework.runtime.model.SpecInfo; + +import java.util.Collection; + +public interface SpecProcessor { + void process(Collection specs); +} diff --git a/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/orderer/SpecOrderer.java b/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/orderer/SpecOrderer.java new file mode 100644 index 0000000000..70bff7262a --- /dev/null +++ b/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/orderer/SpecOrderer.java @@ -0,0 +1,35 @@ +package org.spockframework.runtime.extension.builtin.orderer; + +import org.spockframework.runtime.SpecProcessor; +import org.spockframework.runtime.model.SpecInfo; + +import java.util.Collection; + +public abstract class SpecOrderer implements SpecProcessor { + protected final boolean orderSpecs; + protected final boolean orderFeatures; + + public SpecOrderer(boolean orderSpecs, boolean orderFeatures) { + this.orderSpecs = orderSpecs; + this.orderFeatures = orderFeatures; + } + + @Override + public void process(Collection specs) { + if (orderSpecs) + orderSpecs(specs); + if (orderFeatures) + orderFeatures(specs); + } + + protected abstract void orderSpecs(Collection specs); + protected abstract void orderFeatures(Collection specs); + + public boolean isOrderSpecs() { + return orderSpecs; + } + + public boolean isOrderFeatures() { + return orderFeatures; + } +}