ForwardingRead[Only]/WriteTransaction implementations
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / md / sal / binding / api / ForwardingReadOnlyTransaction.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 org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17
18 /**
19  * Utility {@link ReadOnlyTransaction} implementation which forwards all interface method
20  * invocation to a delegate instance.
21  */
22 @SuppressWarnings("deprecation") // due to CheckedFuture
23 public class ForwardingReadOnlyTransaction extends ForwardingObject implements ReadOnlyTransaction {
24
25     private final ReadOnlyTransaction delegate;
26
27     protected ForwardingReadOnlyTransaction(ReadOnlyTransaction delegate) {
28         super();
29         this.delegate = delegate;
30     }
31
32     @Override
33     protected ReadTransaction delegate() {
34         return delegate;
35     }
36
37     @Override
38     public <T extends DataObject> CheckedFuture<Optional<T>, ReadFailedException> read(LogicalDatastoreType store,
39             InstanceIdentifier<T> path) {
40         return delegate.read(store, path);
41     }
42
43     @Override
44     public Object getIdentifier() {
45         return delegate.getIdentifier();
46     }
47
48     @Override
49     public void close() {
50         delegate.close();
51     }
52 }

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