From: Mathieu Baudier Date: Mon, 13 Feb 2012 09:16:16 +0000 (+0000) Subject: Improve If X-Git-Tag: argeo-slc-2.1.7~805 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=a2ecbd2a3eae94576fe4db3d651bc0908245da90;hp=720f7c1d69e578dc19a2032f14f9324c58cae5c4;p=gpl%2Fargeo-slc.git Improve If git-svn-id: https://svn.argeo.org/slc/trunk@5059 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 index e8ec936e2..f8a79d848 100644 --- 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 @@ -4,14 +4,18 @@ import org.argeo.slc.SlcException; /** Conditional execution */ public class If implements Runnable { - private Boolean bool; + private Boolean is; + private Boolean not; private Runnable then; private Runnable els; public void run() { - if (bool == null) + if (is == null && not == null) throw new SlcException("No condition set"); + if (is != null && not != null) + throw new SlcException("Both is and not cannot be set"); + boolean bool = (is != null ? is : !not); if (bool) { if (then != null) then.run(); @@ -22,8 +26,8 @@ public class If implements Runnable { } - public void setBool(Boolean bool) { - this.bool = bool; + public void setIs(Boolean bool) { + this.is = bool; } public void setThen(Runnable then) { @@ -34,4 +38,12 @@ public class If implements Runnable { this.els = els; } + public Boolean getNot() { + return not; + } + + public void setNot(Boolean not) { + this.not = not; + } + }