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 com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.mdsal.common.api.TransactionDatastoreMismatchException;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 * Write-like operations supported by {@link WriteTransaction} and {@link ReadWriteTransaction}. This interface defines
19 * the operations without a tie-in with lifecycle management.
21 public interface WriteOperations {
23 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that
24 * whole subtree will be replaced by the specified data.
27 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
28 * put, consider using {@link #merge} instead.
30 * @param store the logical data store which should be modified
31 * @param path the data object path
32 * @param data the data object to be written to the specified path
33 * @throws IllegalStateException if the transaction has already been submitted
34 * @throws NullPointerException if any of the arguments is {@code null}
35 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
37 <T extends DataObject> void put(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
41 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
42 * subtree will be replaced by the specified data. Unlike
43 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
44 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
47 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
48 * put, consider using {@link #merge} instead.
51 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
52 * a previous transaction. It also has a significantly higher cost than
53 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)} and should only be used when
54 * absolutely necessary.
56 * @param store the logical data store which should be modified
57 * @param path the data object path
58 * @param data the data object to be written to the specified path
59 * @throws IllegalStateException if the transaction has already been submitted
60 * @throws NullPointerException if any of the arguments is {@code null}
61 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
63 // TODO: can we come up with a better name?
65 <T extends DataObject> void mergeParentStructurePut(@NonNull LogicalDatastoreType store,
66 @NonNull InstanceIdentifier<T> path, @NonNull T data);
69 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
70 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
73 * If you require an explicit replace operation, use {@link #put} instead.
75 * @param store the logical data store which should be modified
76 * @param path the data object path
77 * @param data the data object to be merged to the specified path
78 * @throws IllegalStateException if the transaction has already been submitted
79 * @throws NullPointerException if any of the arguments is {@code null}
80 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
82 <T extends DataObject> void merge(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
86 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
87 * overwritten will be preserved. This means that if you store a container, its child lists will be merged. Unlike
88 * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
89 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
92 * If you require an explicit replace operation, use {@link #put} instead.
95 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
96 * a previous transaction. It is not necessary in most scenarios and has a significantly higher cost
97 * than {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}. It should only be used
98 * when absolutely necessary.
100 * @param store the logical data store which should be modified
101 * @param path the data object path
102 * @param data the data object to be merged to the specified path
103 * @throws IllegalStateException if the transaction has already been submitted
104 * @throws NullPointerException if any of the arguments is {@code null}
105 * @throws TransactionDatastoreMismatchException if this transaction is already bound to a different data store
107 // TODO: can we come up with a better name?
109 <T extends DataObject> void mergeParentStructureMerge(@NonNull LogicalDatastoreType store,
110 @NonNull InstanceIdentifier<T> path, @NonNull T data);
113 * Removes a piece of data from specified path. This operation does not fail if the specified path does not exist.
115 * @param store Logical data store which should be modified
116 * @param path Data object path
117 * @throws IllegalStateException if the transaction was committed or canceled.
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
121 void delete(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);