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.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 null
35 <T extends DataObject> void put(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
39 * Stores a piece of data at the specified path. This acts as an add / replace operation, which is to say that whole
40 * subtree will be replaced by the specified data. Unlike
41 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
42 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
45 * If you need to make sure that a parent object exists but you do not want modify its pre-existing state by using
46 * put, consider using {@link #merge} instead.
49 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
50 * a previous transaction. It also has a significantly higher cost than
51 * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject)} and should only be used when
52 * absolutely necessary.
54 * @param store the logical data store which should be modified
55 * @param path the data object path
56 * @param data the data object to be written to the specified path
57 * @throws IllegalStateException if the transaction has already been submitted
58 * @throws NullPointerException if any of the arguments is null
60 // TODO: can we come up with a better name?
62 <T extends DataObject> void mergeParentStructurePut(@NonNull LogicalDatastoreType store,
63 @NonNull InstanceIdentifier<T> path, @NonNull T data);
66 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
67 * overwritten will be preserved. This means that if you store a container, its child lists will be merged.
70 * If you require an explicit replace operation, use {@link #put} instead.
72 * @param store the logical data store which should be modified
73 * @param path the data object path
74 * @param data the data object to be merged to the specified path
75 * @throws IllegalStateException if the transaction has already been submitted
76 * @throws NullPointerException if any of the arguments is null
78 <T extends DataObject> void merge(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<T> path,
82 * Merges a piece of data with the existing data at a specified path. Any pre-existing data which is not explicitly
83 * overwritten will be preserved. This means that if you store a container, its child lists will be merged. Unlike
84 * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}, this method will attempt to create
85 * semantically-significant parent nodes, like list entries and presence containers, as indicated by {@code path}.
88 * If you require an explicit replace operation, use {@link #put} instead.
91 * <b>WARNING:</b> Using this method may introduce garbage in data store, or recreate nodes, which were deleted by
92 * a previous transaction. It is not necessary in most scenarios and has a significantly higher cost
93 * than {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject)}. It should only be used
94 * when absolutely necessary.
96 * @param store the logical data store which should be modified
97 * @param path the data object path
98 * @param data the data object to be merged to the specified path
99 * @throws IllegalStateException if the transaction has already been submitted
100 * @throws NullPointerException if any of the arguments is null
102 // TODO: can we come up with a better name?
104 <T extends DataObject> void mergeParentStructureMerge(@NonNull LogicalDatastoreType store,
105 @NonNull InstanceIdentifier<T> path, @NonNull T data);
108 * Removes a piece of data from specified path. This operation does not fail if the specified path does not exist.
110 * @param store Logical data store which should be modified
111 * @param path Data object path
112 * @throws IllegalStateException if the transaction was committed or canceled.
114 void delete(@NonNull LogicalDatastoreType store, @NonNull InstanceIdentifier<?> path);