conditional.java

来自「一个很好的微工作流内核」· Java 代码 · 共 64 行

JAVA
64
字号
/* * 	  *  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 + =
减小字号Ctrl + -
显示快捷键?