2 * Copyright (c) 2016 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.mdsal.binding.dom.adapter;
10 import com.google.common.util.concurrent.CheckedFuture;
11 import javax.annotation.Nullable;
12 import org.opendaylight.mdsal.binding.api.CursorAwareWriteTransaction;
13 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.mdsal.binding.api.DataTreeWriteCursor;
15 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
17 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 public class BindingDOMCursorAwareWriteTransactionAdapter<T extends DOMDataTreeCursorAwareTransaction>
23 extends AbstractBindingAdapter<T> implements CursorAwareWriteTransaction {
25 public BindingDOMCursorAwareWriteTransactionAdapter(final T delegate, final BindingToNormalizedNodeCodec codec) {
26 super(codec, delegate);
31 public <P extends DataObject> DataTreeWriteCursor createCursor(final DataTreeIdentifier<P> path) {
32 final YangInstanceIdentifier yPath = getCodec().toNormalized(path.getRootIdentifier());
33 final DOMDataTreeWriteCursor cursor = getDelegate().createCursor(
34 new DOMDataTreeIdentifier(path.getDatastoreType(), yPath));
35 return new BindingDOMDataTreeWriteCursorAdapter<>(path, cursor, getCodec());
39 public boolean cancel() {
40 return getDelegate().cancel();
44 public CheckedFuture<Void, TransactionCommitFailedException> submit() {
45 return getDelegate().submit();