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.controller.md.sal.binding.api;
10 import org.opendaylight.controller.md.sal.common.api.data.AsyncWriteTransaction;
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16 * A transaction that provides mutation capabilities on a data tree.
19 * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
21 public interface WriteTransaction extends AsyncWriteTransaction<InstanceIdentifier<?>, DataObject> {
23 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
24 * subtree will be replaced by the specified data.
27 * This method does not automatically create missing parent nodes. It is equivalent to invoking
28 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents} set
32 * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
35 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
36 * put, consider using {@link #merge} instead.
38 * @param store the logical data store which should be modified
39 * @param path the data object path
40 * @param data the data object to be written to the specified path
41 * @throws IllegalStateException if the transaction has already been submitted
43 <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
46 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
47 * subtree will be replaced by the specified data.
50 * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
53 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
54 * put, consider using {@link #merge} instead.
57 * Note: Using <code>createMissingParents</code> with value true, may introduce garbage in data store, or recreate
58 * nodes, which were deleted by previous transaction.
60 * @param store the logical data store which should be modified
61 * @param path the data object path
62 * @param data the data object to be written to the specified path
63 * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be
64 * automatically created using a merge operation.
65 * @throws IllegalStateException if the transaction has already been submitted
67 <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
68 boolean createMissingParents);
71 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
72 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
75 * This method does not automatically create missing parent nodes. It is equivalent to invoking
76 * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)} with {@code createMissingParents}
80 * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
83 * If you require an explicit replace operation, use {@link #put} instead.
85 * @param store the logical data store which should be modified
86 * @param path the data object path
87 * @param data the data object to be merged to the specified path
88 * @throws IllegalStateException if the transaction has already been submitted
90 <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
93 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
94 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
97 * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
100 * If you require an explicit replace operation, use {@link #put} instead.
102 * @param store the logical data store which should be modified
103 * @param path the data object path
104 * @param data the data object to be merged to the specified path
105 * @param createMissingParents if {@link #CREATE_MISSING_PARENTS} ({@code true}), any missing parent nodes will be
106 * automatically created using a merge operation.
107 * @throws IllegalStateException if the transaction has already been submitted
109 <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
110 boolean createMissingParents);
113 void delete(LogicalDatastoreType store, InstanceIdentifier<?> path);
116 * Flag value indicating that missing parents should be created.
118 boolean CREATE_MISSING_PARENTS = true;
121 * Flag value indicating that missing parents should cause an error.
123 boolean FAIL_ON_MISSING_PARENTS = false;