Add forwarding transactions to binding v2
[mdsal.git] / binding2 / mdsal-binding2-spi / src / main / java / org / opendaylight / mdsal / binding / javav2 / spi / ForwardingWriteTransaction.java
1 /*
2  * Copyright © 2017, 2018 Red Hat, Inc. and others.
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.mdsal.binding.javav2.spi;
9
10 import com.google.common.collect.ForwardingObject;
11 import com.google.common.util.concurrent.FluentFuture;
12 import org.opendaylight.mdsal.binding.javav2.api.WriteTransaction;
13 import org.opendaylight.mdsal.binding.javav2.spec.base.InstanceIdentifier;
14 import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
15 import org.opendaylight.mdsal.common.api.CommitInfo;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17
18 /**
19  * Utility {@link WriteTransaction} implementation which forwards all interface method
20  * invocation to a delegate instance.
21  */
22 public class ForwardingWriteTransaction extends ForwardingObject implements WriteTransaction {
23
24     private final WriteTransaction delegate;
25
26     protected ForwardingWriteTransaction(WriteTransaction delegate) {
27         this.delegate = delegate;
28     }
29
30     @Override
31     protected WriteTransaction delegate() {
32         return delegate;
33     }
34
35     @Override
36     public <T extends TreeNode> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
37         delegate.put(store, path, data);
38     }
39
40     @Override
41     public <T extends TreeNode> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
42             boolean createMissingParents) {
43         put(store, path, data, createMissingParents);
44     }
45
46     @Override
47     public <T extends TreeNode> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data) {
48         delegate.merge(store, path, data);
49     }
50
51     @Override
52     public <T extends TreeNode> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
53             boolean createMissingParents) {
54         delegate.merge(store, path, data, createMissingParents);
55     }
56
57     @Override
58     public void delete(LogicalDatastoreType store, InstanceIdentifier<?> path) {
59         delegate.delete(store, path);
60     }
61
62     @Override
63     public boolean cancel() {
64         return delegate.cancel();
65     }
66
67     @Override
68     public FluentFuture<? extends CommitInfo> commit() {
69         return delegate.commit();
70     }
71
72     @Override
73     public Object getIdentifier() {
74         return delegate.getIdentifier();
75     }
76 }