ForwardingRead[Only]/WriteTransaction implementations
[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         super();
33         this.delegate = delegate;
34     }
35
36     @Override
37     protected ReadWriteTransaction delegate() {
38         return delegate;
39     }
40
41     @Override
42     public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
43         delegate.put(store, path, data);
44     }
45
46     @Override
47     public <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
48             boolean createMissingParents) {
49         delegate.put(store, path, data, createMissingParents);
50     }
51
52     @Override
53     public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(LogicalDatastoreType store,
54             InstanceIdentifier<T> path) {
55         return delegate.read(store, path);
56     }
57
58     @Override
59     public Object getIdentifier() {
60         return delegate.getIdentifier();
61     }
62
63     @Override
64     public boolean cancel() {
65         return delegate.cancel();
66     }
67
68     @Override
69     public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
70         delegate.merge(store, path, data);
71     }
72
73     @Override
74     public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
75             boolean createMissingParents) {
76         delegate.merge(store, path, data, createMissingParents);
77     }
78
79     @Override
80     public CheckedFuture<Void, TransactionCommitFailedException> submit() {
81         return delegate.submit();
82     }
83
84     @Override
85     public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
86         delegate.delete(store, path);
87     }
88
89     @Override
90     public ListenableFuture<RpcResult<TransactionStatus>> commit() {
91         return delegate.commit();
92     }
93 }

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