2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.client.mdsal.spi;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.FluentFuture;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.mdsal.common.api.CommitInfo;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
19 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
23 class ReadWriteTx<T extends DOMDataTreeReadTransaction> implements DOMDataTreeReadWriteTransaction {
24 private final DOMDataTreeWriteTransaction delegateWriteTx;
25 final T delegateReadTx;
27 ReadWriteTx(final T delegateReadTx, final DOMDataTreeWriteTransaction delegateWriteTx) {
28 this.delegateReadTx = requireNonNull(delegateReadTx);
29 this.delegateWriteTx = requireNonNull(delegateWriteTx);
33 public final FluentFuture<?> completionFuture() {
34 return delegateWriteTx.completionFuture();
38 public final boolean cancel() {
39 return delegateWriteTx.cancel();
43 public final void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
44 final NormalizedNode data) {
45 delegateWriteTx.put(store, path, data);
49 public final void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
50 final NormalizedNode data) {
51 delegateWriteTx.merge(store, path, data);
55 public final void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
56 delegateWriteTx.delete(store, path);
60 public final FluentFuture<? extends @NonNull CommitInfo> commit() {
61 return delegateWriteTx.commit();
65 public final FluentFuture<Optional<NormalizedNode>> read(final LogicalDatastoreType store,
66 final YangInstanceIdentifier path) {
67 return delegateReadTx.read(store, path);
71 public final FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
72 return delegateReadTx.exists(store, path);
76 public final Object getIdentifier() {