MDSAL-API Migration
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / infra / NonSubmitCancelableWriteTransaction.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.genius.infra;
9
10 import com.google.common.util.concurrent.FluentFuture;
11 import org.opendaylight.mdsal.binding.api.WriteTransaction;
12 import org.opendaylight.mdsal.common.api.CommitInfo;
13
14 /**
15  * WriteTransaction which cannot be {@link WriteTransaction#cancel()},
16  * {@link WriteTransaction#commit()} or {@link WriteTransaction#submit()}.
17  *
18  * @author Michael Vorburger.ch
19  */
20 // intentionally package local, for now
21 class NonSubmitCancelableWriteTransaction extends WriteTrackingWriteTransaction {
22
23     // TODO if we could finally reach consensus on https://git.opendaylight.org/gerrit/#/c/46684/, then this could probably be removed?
24     // see also https://git.opendaylight.org/gerrit/#/c/46335/ for the earlier take on it - controller, mdsal, controller, mdsal... ;-)
25
26     NonSubmitCancelableWriteTransaction(WriteTransaction delegate) {
27         super(delegate);
28     }
29
30     @Override
31     public boolean cancel() {
32         throw new UnsupportedOperationException("cancel() cannot be used inside a Managed[New]TransactionRunner");
33     }
34
35     @Override
36     public FluentFuture<? extends CommitInfo> commit() {
37         throw new UnsupportedOperationException("commit() cannot be used inside a Managed[New]TransactionRunner");
38     }
39 }