97a6db64195454f997d34c6cb55079472f35c477
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / ForwardingReadWriteTransaction.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.controller.md.sal.binding.api;
9
10 import com.google.common.base.Optional;
11 import com.google.common.collect.ForwardingObject;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
17 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21
22 /**
23  * Utility {@link ReadWriteTransaction} implementation which forwards all interface method
24  * invocation to a delegate instance.
25  */
26 @SuppressWarnings("deprecation") // due to CheckedFuture & TransactionStatus
27 public class ForwardingReadWriteTransaction extends ForwardingObject implements ReadWriteTransaction {
28
29     private final ReadWriteTransaction delegate;
30
31     protected ForwardingReadWriteTransaction(ReadWriteTransaction delegate) {
32         this.delegate = delegate;
33     }
34
35     @Override
36     protected ReadWriteTransaction delegate() {
37         return delegate;
38     }
39
40     @Override
41     public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
42         delegate.put(store, path, data);
43     }
44
45     @Override
46     public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
47             boolean createMissingParents) {
48         delegate.put(store, path, data, createMissingParents);
49     }
50
51     @Override
52     public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(LogicalDatastoreType store,
53             InstanceIdentifier<T> path) {
54         return delegate.read(store, path);
55     }
56
57     @Override
58     public Object getIdentifier() {
59         return delegate.getIdentifier();
60     }
61
62     @Override
63     public boolean cancel() {
64         return delegate.cancel();
65     }
66
67     @Override
68     public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
69         delegate.merge(store, path, data);
70     }
71
72     @Override
73     public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
74             boolean createMissingParents) {
75         delegate.merge(store, path, data, createMissingParents);
76     }
77
78     @Override
79     public CheckedFuture<Void, TransactionCommitFailedException> submit() {
80         return delegate.submit();
81     }
82
83     @Override
84     public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
85         delegate.delete(store, path);
86     }
87
88     @Override
89     public ListenableFuture<RpcResult<TransactionStatus>> commit() {
90         return delegate.commit();
91     }
92 }

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