From: Mathieu Baudier Date: Sun, 12 Feb 2012 17:40:43 +0000 (+0000) Subject: Introduce conditional task X-Git-Tag: argeo-slc-2.1.7~809 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=6262bde34e00443e9994c3b68803eab03d287379;p=gpl%2Fargeo-slc.git Introduce conditional task git-svn-id: https://svn.argeo.org/slc/trunk@5055 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/If.java b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/If.java new file mode 100644 index 000000000..e8ec936e2 --- /dev/null +++ b/runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/If.java @@ -0,0 +1,37 @@ +package org.argeo.slc.core.execution.tasks; + +import org.argeo.slc.SlcException; + +/** Conditional execution */ +public class If implements Runnable { + private Boolean bool; + private Runnable then; + private Runnable els; + + public void run() { + if (bool == null) + throw new SlcException("No condition set"); + + if (bool) { + if (then != null) + then.run(); + } else { + if (els != null) + els.run(); + } + + } + + public void setBool(Boolean bool) { + this.bool = bool; + } + + public void setThen(Runnable then) { + this.then = then; + } + + public void setEls(Runnable els) { + this.els = els; + } + +}