2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.api;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
12 import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 * Write-like operations supported by {@link WriteTransaction} and {@link ReadWriteTransaction}. This interface defines
18 * the operations without a tie-in with lifecycle management.
20 public interface WriteOperations {
22 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that
23 * whole subtree will be replaced by the specified data.
26 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
27 * put, consider using {@link #merge} instead.
29 * @param store the logical data store which should be modified
30 * @param path the data object path
31 * @param data the data object to be written to the specified path
32 * @throws IllegalStateException if the transaction has already been submitted
33 * @throws NullPointerException if any of the arguments is {@code null}
34 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
36 <T extends DataObject> void put(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
40 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
41 * subtree will be replaced by the specified data. Unlike
42 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
43 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
46 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
47 * put, consider using {@link #merge} instead.
50 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
51 * a previous transaction. It also has a significantly higher cost than
52 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)} and should only be used when
53 * absolutely necessary.
55 * @param store the logical data store which should be modified
56 * @param path the data object path
57 * @param data the data object to be written to the specified path
58 * @throws IllegalStateException if the transaction has already been submitted
59 * @throws NullPointerException if any of the arguments is {@code null}
60 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
61 * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
62 * parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
63 * all the cases which do not attach semantics, such as {@code container}s without {@code presence},
64 * {@code augmentation} and {@code list} encapsulation.
65 * This method does not work in the general case, where there are:
67 * <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
68 * boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
69 * to create an invalid structure</li>
70 * <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
71 * can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
74 * Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
75 * relationship with entities responsible for managing such semantic items which are created by this
78 @Deprecated(since = "11.0.3")
79 <T extends DataObject> void mergeParentStructurePut(@NonNull LogicalDatastoreType store,
80 @NonNull InstanceIdentifier<T> path, @NonNull T data);
83 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
84 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
87 * If you require an explicit replace operation, use {@link #put} instead.
89 * @param store the logical data store which should be modified
90 * @param path the data object path
91 * @param data the data object to be merged to the specified path
92 * @throws IllegalStateException if the transaction has already been submitted
93 * @throws NullPointerException if any of the arguments is {@code null}
94 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
96 <T extends DataObject> void merge(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
100 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
101 * overwritten will be preserved. This means that if you store a container, its child lists will be merged. Unlike
102 * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
103 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
106 * If you require an explicit replace operation, use {@link #put} instead.
109 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
110 * a previous transaction. It is not necessary in most scenarios and has a significantly higher cost
111 * than {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}. It should only be used
112 * when absolutely necessary.
114 * @param store the logical data store which should be modified
115 * @param path the data object path
116 * @param data the data object to be merged to the specified path
117 * @throws IllegalStateException if the transaction has already been submitted
118 * @throws NullPointerException if any of the arguments is {@code null}
119 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
120 * @deprecated Use of this method is a manifestation of bad lifecycle management: it attempts to create data tree
121 * parent nodes which may have semantic meaning without assigning responsibility. The datastore handles
122 * all the cases which do not attach semantics, such as {@code container}s without {@code presence},
123 * {@code augmentation} and {@code list} encapsulation.
124 * This method does not work in the general case, where there are:
126 * <li>{@code container} parents with {@code presence}, as these form a {@code mandatory} enforcement
127 * boundary. We cannot infer the mandatory nodes from {@code path} and hence we may end up wanting
128 * to create an invalid structure</li>
129 * <li>{@code list} parents with {@code unique} encompassing other leaves than {@code key}. While we
130 * can re-create the key {@code leaf} items, we have no way of constructing of {@code unique}
133 * Based on this analysis, all users of this method need to be migrated to have a proper lifecycle
134 * relationship with entities responsible for managing such semantic items which are created by this
137 @Deprecated(since = "11.0.3")
138 <T extends DataObject> void mergeParentStructureMerge(@NonNull LogicalDatastoreType store,
139 @NonNull InstanceIdentifier<T> path, @NonNull T data);
142 * Removes a piece of data from specified path. This operation does not fail if the specified path does not exist.
144 * @param store Logical data store which should be modified
145 * @param path Data object path
146 * @throws IllegalStateException if the transaction was committed or canceled.
147 * @throws NullPointerException if any of the arguments is {@code null}
148 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
150 void delete(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);