Proxy MD-SAL interfaces in DOMMountPointServiceImpl
[controller.git] / opendaylight / md-sal / sal-dom-compat / src / main / java / org / opendaylight / controller / sal / core / compat / TransactionUtils.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.sal.core.compat;
9
10 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.fromMdsal;
11
12 import com.google.common.util.concurrent.FluentFuture;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.Optional;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
17 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20
21 final class TransactionUtils {
22     private TransactionUtils() {
23
24     }
25
26     static FluentFuture<Boolean> exists(final DOMDataReadTransaction tx,
27             final LogicalDatastoreType store, final YangInstanceIdentifier path) {
28         return FluentFuture.from(tx.exists(fromMdsal(store), path));
29     }
30
31     static FluentFuture<Optional<NormalizedNode<?, ?>>> read(final DOMDataReadTransaction tx,
32             final LogicalDatastoreType store, final YangInstanceIdentifier path) {
33         return FluentFuture.from(tx.read(fromMdsal(store), path)).transform(opt -> opt.toJavaUtil(),
34             MoreExecutors.directExecutor());
35     }
36
37     static void delete(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
38             final YangInstanceIdentifier path) {
39         tx.delete(fromMdsal(store), path);
40     }
41
42     static void merge(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
43             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
44         tx.merge(fromMdsal(store), path, data);
45     }
46
47     static void put(final DOMDataWriteTransaction tx, final LogicalDatastoreType store,
48             final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
49         tx.put(fromMdsal(store), path, data);
50     }
51 }

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