aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/common/test/BaseRunnable.java
blob: 3e182083d2f9ed4acb6b1fa76ed32af78959b559 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cz.crcs.ectester.common.test;

/**
 * @author Jan Jancar johny@neuromancer.sk
 */
public class BaseRunnable implements Runnable {
    private boolean hasRun = false;
    private Func runImplicit;

    public BaseRunnable(Func runImplicit) {
        this.runImplicit = runImplicit;
    }

    @Override
    public boolean hasRun() {
        return hasRun;
    }

    @Override
    public void run() throws TestException {
        if (!hasRun) {
            runImplicit.run();
        }
        hasRun = true;
    }

    @FunctionalInterface
    public interface Func {
        void run() throws TestException;
    }
}