aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-utils/src/main/java/com/yahoo/vespa/clustercontroller/utils/communication/async/SuccessfulAsyncCallback.java
blob: 87c6956b845c37af273917d15a346e3e2e8cf6ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.async;

public abstract class SuccessfulAsyncCallback<Source, Target> implements AsyncCallback<Source> {

    private final AsyncOperationImpl<Target> target;

    public SuccessfulAsyncCallback(final AsyncOperationImpl<Target> target) {
        this.target = target;
    }

    public void done(AsyncOperation<Source> sourceOp) {
        if (sourceOp.isSuccess()) {
            successfullyDone(sourceOp);
        } else {
            target.setFailure(sourceOp.getCause());
        }
    }

    public abstract void successfullyDone(AsyncOperation<Source> op);

}