Proxy MD-SAL interfaces in DOMMountPointServiceImpl
[controller.git] / opendaylight / md-sal / sal-dom-compat / src / main / java / org / opendaylight / controller / sal / core / compat / DOMDataTreeReadWriteTransactionAdapter.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.controller.sal.core.compat;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ForwardingObject;
13 import com.google.common.util.concurrent.FluentFuture;
14 import java.util.Optional;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
16 import org.opendaylight.mdsal.common.api.CommitInfo;
17 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21
22 public class DOMDataTreeReadWriteTransactionAdapter extends ForwardingObject
23         implements DOMDataTreeReadWriteTransaction {
24     private final DOMDataReadWriteTransaction delegate;
25
26     public DOMDataTreeReadWriteTransactionAdapter(final DOMDataReadWriteTransaction delegate) {
27         this.delegate = requireNonNull(delegate);
28     }
29
30     @Override
31     public Object getIdentifier() {
32         return delegate().getIdentifier();
33     }
34
35     @Override
36     public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final LogicalDatastoreType store,
37             final YangInstanceIdentifier path) {
38         return TransactionUtils.read(delegate(), store, path);
39     }
40
41     @Override
42     public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
43         return TransactionUtils.exists(delegate(), store, path);
44     }
45
46     @Override
47     public void close() {
48         cancel();
49     }
50
51     @Override
52     public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
53             final NormalizedNode<?, ?> data) {
54         TransactionUtils.put(delegate(), store, path, data);
55     }
56
57     @Override
58     public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
59             final NormalizedNode<?, ?> data) {
60         TransactionUtils.merge(delegate(), store, path, data);
61     }
62
63     @Override
64     public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
65         TransactionUtils.delete(delegate(), store, path);
66     }
67
68     @Override
69     public FluentFuture<? extends CommitInfo> commit() {
70         return delegate().commit();
71     }
72
73     @Override
74     public boolean cancel() {
75         return delegate().cancel();
76     }
77
78     @Override
79     protected DOMDataReadWriteTransaction delegate() {
80         return delegate;
81     }
82 }

©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.