X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2Ftasks%2FIf.java;h=0d22e437d9bff996cd73ebc0b7d21bd0070206a9;hb=a75c0516aca20f9a8c8fdd32feee402257ff2b61;hp=e8ec936e29382d74144a784f2a60192f7e60eacd;hpb=6262bde34e00443e9994c3b68803eab03d287379;p=gpl%2Fargeo-slc.git 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..0d22e437d 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 @@ -1,17 +1,36 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.slc.core.execution.tasks; 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 +41,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 +53,12 @@ public class If implements Runnable { this.els = els; } + public Boolean getNot() { + return not; + } + + public void setNot(Boolean not) { + this.not = not; + } + }