]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/tasks/If.java
Improve If
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / tasks / If.java
index e8ec936e29382d74144a784f2a60192f7e60eacd..f8a79d84849ae5abe4179ab9fedbdd30077e1f06 100644 (file)
@@ -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;
+       }
+
 }