Fix checkstyle issues in module sal-dom-broker
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / legacy / sharded / adapter / ShardedDOMDataBrokerDelegatingWriteTransaction.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, 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
9 package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
10
11 import static com.google.common.base.Preconditions.checkNotNull;
12
13 import com.google.common.util.concurrent.CheckedFuture;
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
17 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
18 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
19 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
20 import org.opendaylight.controller.md.sal.dom.broker.impl.TransactionCommitFailedExceptionMapper;
21 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
22 import org.opendaylight.yangtools.yang.common.RpcResult;
23 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
25 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
26
27 class ShardedDOMDataBrokerDelegatingWriteTransaction implements DOMDataWriteTransaction {
28     private static final ListenableFuture<RpcResult<TransactionStatus>> SUCCESS_FUTURE = Futures
29             .immediateFuture(RpcResultBuilder.success(TransactionStatus.COMMITED).build());
30
31     private final DOMDataTreeWriteTransaction delegateTx;
32     private final Object txIdentifier;
33
34     ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier,
35                                                           final DOMDataTreeWriteTransaction delegateTx) {
36         this.delegateTx = checkNotNull(delegateTx);
37         this.txIdentifier = checkNotNull(txIdentifier);
38     }
39
40     @Override
41     public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
42                     final NormalizedNode<?, ?> data) {
43         delegateTx.put(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path, data);
44     }
45
46     @Override
47     public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
48                       final NormalizedNode<?, ?> data) {
49         delegateTx.merge(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path, data);
50     }
51
52     @Override
53     public boolean cancel() {
54         return delegateTx.cancel();
55     }
56
57     @Override
58     public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
59         delegateTx.delete(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path);
60     }
61
62     @Override
63     public CheckedFuture<Void, TransactionCommitFailedException> submit() {
64         return Futures.makeChecked(delegateTx.submit(), TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER);
65     }
66
67     @Override
68     public ListenableFuture<RpcResult<TransactionStatus>> commit() {
69         return Futures.transformAsync(submit(), input -> SUCCESS_FUTURE);
70     }
71
72     @Override
73     public Object getIdentifier() {
74         return txIdentifier;
75     }
76 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.