adapter;
- private final Component component;
+ /**
+ * 适配组件,可以是个子流程
+ */
+ private Component
component;
- public AdapterBuilder(Adapter adapter, Component component) {
+ public AdapterBuilder adapter(Adapter adapter) {
+ AssertUtil.notNull(adapter, "adapter must not be null!");
this.adapter = adapter;
+ return this;
+ }
+
+ public AdapterBuilder component(Component component) {
+ AssertUtil.notNull(component, "component must not be null!");
this.component = component;
+ return this;
}
+ @Override
public AdapterComponent build() {
AdapterComponent adapterComponent = new AdapterComponent<>();
adapterComponent.setAdapter(adapter);
@@ -44,4 +62,9 @@ public class AdapterBuilder extends ExecutableBuilder {
return this;
}
+ @Override
+ public AdapterBuilder apply(List holders) {
+ super.apply(holders);
+ return this;
+ }
}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/Builders.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/Builders.java
new file mode 100644
index 0000000000000000000000000000000000000000..8f1958890184af2a5b4a2d50f0e17aa4b38604a4
--- /dev/null
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/Builders.java
@@ -0,0 +1,47 @@
+package org.smartboot.flow.core.builder;
+
+/**
+ * Builder Auxiliary Util.
+ *
+ * @author qinluo
+ * @date 2022-11-11 14:54:34
+ * @since 1.0.9
+ */
+public final class Builders {
+
+ public static ChooseBuilder newChoose() {
+ return new ChooseBuilder<>();
+ }
+
+ public static AdapterBuilder newAdapter() {
+ return new AdapterBuilder<>();
+ }
+
+ public static IfComponentBuilder newIf() {
+ return new IfComponentBuilder<>();
+ }
+
+ public static EngineBuilder engine() {
+ return new EngineBuilder<>();
+ }
+
+ public static PipelineBuilder pipeline() {
+ return new PipelineBuilder<>();
+ }
+
+ public static ScriptBuilder script() {
+ return new ScriptBuilder<>();
+ }
+
+ public static ScriptExecutableBuilder scriptExecutable() {
+ return new ScriptExecutableBuilder<>();
+ }
+
+ public static ExecutableBuilder executable() {
+ return new ExecutableBuilder<>();
+ }
+
+ public static PipelineComponentBuilder pipelineRef() {
+ return new PipelineComponentBuilder<>();
+ }
+}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/CaseBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/CaseBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..13367bae49fbb3fd5338767c3613c91f6989912d
--- /dev/null
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/CaseBuilder.java
@@ -0,0 +1,39 @@
+package org.smartboot.flow.core.builder;
+
+import org.smartboot.flow.core.component.Component;
+import org.smartboot.flow.core.executable.Executable;
+import org.smartboot.flow.core.executable.ExecutableAdapter;
+import org.smartboot.flow.core.util.AssertUtil;
+
+/**
+ * @author qinluo
+ * @date 2022-11-11 14:54:34
+ * @since 1.0.9
+ */
+public class CaseBuilder {
+
+ /**
+ * Case condition.
+ */
+ private final Object when;
+
+ private final ChooseBuilder chooseBuilder;
+
+ CaseBuilder(ChooseBuilder chooseBuilder, Object when) {
+ this.when = when;
+ this.chooseBuilder = chooseBuilder;
+ }
+
+ public ChooseBuilder then(Component branch) {
+ AssertUtil.notNull(branch, "branch must not be null");
+ chooseBuilder.addBranch(when, branch);
+ return chooseBuilder;
+ }
+
+ public ChooseBuilder then(Executable branch) {
+ AssertUtil.notNull(branch, "branch must not be null");
+ ExecutableAdapter adapter = new ExecutableAdapter<>();
+ adapter.setExecutable(branch);
+ return then(adapter);
+ }
+}
diff --git a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java
index dee14910166e26a8ad174f871fb353c4a375aee5..2d73e348a085488d860f1d0ed3dbab35c2a13247 100644
--- a/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java
+++ b/smart-flow-core/src/main/java/org/smartboot/flow/core/builder/ChooseBuilder.java
@@ -2,6 +2,7 @@ package org.smartboot.flow.core.builder;
import org.smartboot.flow.core.Condition;
+import org.smartboot.flow.core.attribute.AttributeHolder;
import org.smartboot.flow.core.attribute.AttributeValueResolver;
import org.smartboot.flow.core.attribute.Attributes;
import org.smartboot.flow.core.component.ChooseComponent;
@@ -9,6 +10,7 @@ import org.smartboot.flow.core.component.Component;
import org.smartboot.flow.core.executable.Executable;
import org.smartboot.flow.core.util.AssertUtil;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -17,65 +19,56 @@ import java.util.concurrent.ConcurrentHashMap;
* @date 2022-11-11 14:54:34
* @since 1.0.0
*/
-public class ChooseBuilder extends ExecutableBuilder {
+public class ChooseBuilder extends AbstractComponentBuilder {
- /**
- * PipelineBuilder
- */
- private final PipelineBuilder pipelineBuilder;
- private final Condition condition;
+ private Condition condition;
private final Map