ForwardingRead[Only]/WriteTransaction implementations
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / ForwardingWriteTransaction.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.collect.ForwardingObject;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
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.TransactionCommitFailedException;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20
21 /**
22  * Utility {@link WriteTransaction} implementation which forwards all interface method
23  * invocation to a delegate instance.
24  */
25 @SuppressWarnings("deprecation") // due to CheckedFuture & TransactionStatus
26 public class ForwardingWriteTransaction extends ForwardingObject implements WriteTransaction {
27
28     private final WriteTransaction delegate;
29
30     protected ForwardingWriteTransaction(WriteTransaction delegate) {
31         super();
32         this.delegate = delegate;
33     }
34
35     @Override
36     protected WriteTransaction 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> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
53         delegate.merge(store, path, data);
54     }
55
56     @Override
57     public <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
58             boolean createMissingParents) {
59         delegate.merge(store, path, data, createMissingParents);
60     }
61
62     @Override
63     public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
64         delegate.delete(store, path);
65     }
66
67     @Override
68     public boolean cancel() {
69         return delegate.cancel();
70     }
71
72     @Override
73     public CheckedFuture<Void, TransactionCommitFailedException> submit() {
74         return delegate.submit();
75     }
76
77     @Override
78     public ListenableFuture<RpcResult<TransactionStatus>> commit() {
79         return delegate.commit();
80     }
81
82     @Override
83     public Object getIdentifier() {
84         return delegate.getIdentifier();
85     }
86
87 }

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