7782e797127176eb2fa89418ce1f19ede7b9a5a4
[mdsal.git] / binding / mdsal-binding-util / src / main / java / org / opendaylight / mdsal / binding / util / TypedWriteTransaction.java
1 /*
2  * Copyright © 2018 Red Hat, Inc. and others.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.util;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.mdsal.binding.api.Transaction;
12 import org.opendaylight.mdsal.binding.api.WriteOperations;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.yangtools.yang.binding.DataObject;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 /**
18  * Write transaction which is specific to a single logical datastore (configuration or operational). Designed for use
19  * with {@link ManagedNewTransactionRunner} (it doesn’t support explicit cancel or commit operations).
20  *
21  * @param <D> The logical datastore handled by the transaction.
22  * @see WriteOperations
23  */
24 public interface TypedWriteTransaction<D extends Datastore> extends Transaction {
25     /**
26      * Writes an object to the given path.
27      *
28      * @see WriteOperations#put(LogicalDatastoreType, InstanceIdentifier, DataObject)
29      *
30      * @param path The path to write to.
31      * @param data The object to write.
32      * @param <T> The type of the provided object.
33      */
34     <T extends DataObject> void put(InstanceIdentifier<T> path, T data);
35
36     /**
37      * Writes an object to the given path, creating significant parents, like presence containers and list entries,
38      * if needed.
39      *
40      * @see WriteOperations#mergeParentStructurePut(LogicalDatastoreType, InstanceIdentifier, DataObject)
41      *
42      * @param path The path to write to.
43      * @param data The object to write.
44      * @param <T> The type of the provided object.
45      */
46     // TODO: can we come up with a better name?
47     @Beta
48     <T extends DataObject> void mergeParentStructurePut(InstanceIdentifier<T> path, T data);
49
50     /**
51      * Merges an object with the data already present at the given path.
52      *
53      * @see WriteOperations#merge(LogicalDatastoreType, InstanceIdentifier, DataObject)
54      *
55      * @param path The path to write to.
56      * @param data The object to merge.
57      * @param <T> The type of the provided object.
58      */
59     <T extends DataObject> void merge(InstanceIdentifier<T> path, T data);
60
61     /**
62      * Merges an object with the data already present at the given path, creating missing parents if requested.
63      *
64      * @see WriteOperations#merge(LogicalDatastoreType, InstanceIdentifier, DataObject)
65      *
66      * @param path The path to write to.
67      * @param data The object to merge.
68      * @param <T> The type of the provided object.
69      */
70     // TODO: can we come up with a better name?
71     @Beta
72     <T extends DataObject> void mergeParentStructureMerge(InstanceIdentifier<T> path, T data);
73
74     /**
75      * Deletes the object present at the given path.
76      *
77      * @see WriteOperations#delete(LogicalDatastoreType, InstanceIdentifier)
78      *
79      * @param path The path to delete.
80      */
81     void delete(InstanceIdentifier<?> path);
82 }