📄 conditional.java
字号:
/* * * Copyright (c) 2002 Dragos Manolescu (dam@micro-workflow.com) * * See the LICENSE file for licensing information. */package com.microworkflow.process;import com.microworkflow.execution.ConditionalContinuation;import com.microworkflow.execution.Continuation;/** * @author dam * * This activity node represents an if-then-else conditional; not both branches are * required. The calling continuation replaces the missing branch. */public class Conditional extends Activity { protected TestCondition test; protected Activity thenBranch; protected Activity elseBranch; public Conditional(TestCondition aClosure, Activity thenBranch, Activity elseBranch) { this.test=aClosure; this.thenBranch=thenBranch; this.elseBranch=elseBranch; } public Conditional(TestCondition aClosure, Activity thenBranch) { this(aClosure,thenBranch,null); } public Continuation continuationWith(Continuation continuation) { ConditionalContinuation k = continuation.makeConditionalContinuation(this); k.setTestCondition(test); k.resetState(); return k; } public void setElseBranch(Activity elseBranch) { this.elseBranch = elseBranch; } public void setThenBranch(Activity thenBranch) { this.thenBranch = thenBranch; } public void computeStateFor(Continuation k) { Continuation next=k.getNextContinuation(); ConditionalContinuation ck=(ConditionalContinuation)k; if (thenBranch != null) { ck.setThenContinuation(thenBranch.continuationWith(next)); } else { ck.setThenContinuation(next); } if (elseBranch != null) { ck.setElseContinuation(elseBranch.continuationWith(next)); } else { ck.setElseContinuation(next); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -