summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableBlockingOperation.java
blob: b1a37481a2c278959b386731a88f1f1c1ee862a9 (plain)
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
32
33
34
35
36
37
38
39
package com.keuin.kbackupfabric.operation.abstracts;

import com.keuin.kbackupfabric.operation.abstracts.i.Blocking;

public abstract class InvokableBlockingOperation extends InvokableOperation implements Blocking {

    private final AbstractBlockingOperation operation = new AbstractBlockingOperation() {
        @Override
        protected boolean blockingContext() {
            return InvokableBlockingOperation.this.blockingContext();
        }
    };

    @Override
    protected final boolean operate() {
        return operation.operate();
    }

    /**
     * Implement your blocked operation here.
     *
     * @return stat code.
     */
    protected abstract boolean blockingContext();

    protected void block(boolean blockState) {
        operation.block(blockState);
    }

    protected void noUnblocking(boolean b) {
        operation.noUnblocking(b);
    }

    @Override
    public final boolean isBlocked() {
        return operation.isBlocked();
    }

}