summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/abstracts/InvokableAsyncOperation.java
blob: 518f670acacb48082e3c19dedcdced5247995873 (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
package com.keuin.kbackupfabric.operation.abstracts;

public abstract class InvokableAsyncOperation extends InvokableOperation {

    private final AbstractAsyncOperation asyncOperation;


    public InvokableAsyncOperation(String name) {
        asyncOperation = new AbstractAsyncOperation(name) {
            @Override
            protected void async() {
                InvokableAsyncOperation.this.async();
            }

            @Override
            protected boolean sync() {
                return InvokableAsyncOperation.this.sync();
            }
        };
    }

    protected abstract void async();

    protected boolean sync() {
        return true;
    }

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