]> git.argeo.org Git - gpl/argeo-slc.git/blob - If.java
f8a79d84849ae5abe4179ab9fedbdd30077e1f06
[gpl/argeo-slc.git] / If.java
1 package org.argeo.slc.core.execution.tasks;
2
3 import org.argeo.slc.SlcException;
4
5 /** Conditional execution */
6 public class If implements Runnable {
7 private Boolean is;
8 private Boolean not;
9 private Runnable then;
10 private Runnable els;
11
12 public void run() {
13 if (is == null && not == null)
14 throw new SlcException("No condition set");
15 if (is != null && not != null)
16 throw new SlcException("Both is and not cannot be set");
17
18 boolean bool = (is != null ? is : !not);
19 if (bool) {
20 if (then != null)
21 then.run();
22 } else {
23 if (els != null)
24 els.run();
25 }
26
27 }
28
29 public void setIs(Boolean bool) {
30 this.is = bool;
31 }
32
33 public void setThen(Runnable then) {
34 this.then = then;
35 }
36
37 public void setEls(Runnable els) {
38 this.els = els;
39 }
40
41 public Boolean getNot() {
42 return not;
43 }
44
45 public void setNot(Boolean not) {
46 this.not = not;
47 }
48
49 }