1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.execution.tasks;
17
18 import org.argeo.slc.SlcException;
19
20
21 public class If implements Runnable {
22 private Boolean is;
23 private Boolean not;
24 private Runnable then;
25 private Runnable els;
26
27 public void run() {
28 if (is == null && not == null)
29 throw new SlcException("No condition set");
30 if (is != null && not != null)
31 throw new SlcException("Both is and not cannot be set");
32
33 boolean bool = (is != null ? is : !not);
34 if (bool) {
35 if (then != null)
36 then.run();
37 } else {
38 if (els != null)
39 els.run();
40 }
41
42 }
43
44 public void setIs(Boolean bool) {
45 this.is = bool;
46 }
47
48 public void setThen(Runnable then) {
49 this.then = then;
50 }
51
52 public void setEls(Runnable els) {
53 this.els = els;
54 }
55
56 public Boolean getNot() {
57 return not;
58 }
59
60 public void setNot(Boolean not) {
61 this.not = not;
62 }
63
64 }