Implement managed transactions
[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 org.opendaylight.mdsal.binding.api.Transaction;
11 import org.opendaylight.mdsal.binding.api.WriteTransaction;
12 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 import org.opendaylight.yangtools.yang.binding.DataObject;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
15
16 /**
17  * Write transaction which is specific to a single logical datastore (configuration or operational). Designed for use
18  * with {@link ManagedNewTransactionRunner} (it doesn’t support explicit cancel or commit operations).
19  *
20  * @param <D> The logical datastore handled by the transaction.
21  * @see WriteTransaction
22  */
23 public interface TypedWriteTransaction<D extends Datastore> extends Transaction {
24     /**
25      * Writes an object to the given path.
26      *
27      * @see WriteTransaction#put(LogicalDatastoreType, InstanceIdentifier, DataObject)
28      *
29      * @param path The path to write to.
30      * @param data The object to write.
31      * @param <T> The type of the provided object.
32      */
33     <T extends DataObject> void put(InstanceIdentifier<T> path, T data);
34
35     /**
36      * Writes an object to the given path, creating missing parents if requested.
37      *
38      * @see WriteTransaction#put(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)
39      *
40      * @param path The path to write to.
41      * @param data The object to write.
42      * @param createMissingParents {@link WriteTransaction#CREATE_MISSING_PARENTS} to create missing parents,
43      * {@link WriteTransaction#FAIL_ON_MISSING_PARENTS} to fail if parents are missing.
44      * @param <T> The type of the provided object.
45      */
46     <T extends DataObject> void put(InstanceIdentifier<T> path, T data, boolean createMissingParents);
47
48     /**
49      * Merges an object with the data already present at the given path.
50      *
51      * @see WriteTransaction#merge(LogicalDatastoreType, InstanceIdentifier, DataObject)
52      *
53      * @param path The path to write to.
54      * @param data The object to merge.
55      * @param <T> The type of the provided object.
56      */
57     <T extends DataObject> void merge(InstanceIdentifier<T> path, T data);
58
59     /**
60      * Merges an object with the data already present at the given path, creating missing parents if requested.
61      *
62      * @see WriteTransaction#merge(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)
63      *
64      * @param path The path to write to.
65      * @param data The object to merge.
66      * @param createMissingParents {@link WriteTransaction#CREATE_MISSING_PARENTS} to create missing parents,
67      * {@link WriteTransaction#FAIL_ON_MISSING_PARENTS} to fail if parents are missing.
68      * @param <T> The type of the provided object.
69      */
70     <T extends DataObject> void merge(InstanceIdentifier<T> path, T data, boolean createMissingParents);
71
72     /**
73      * Deletes the object present at the given path.
74      *
75      * @see WriteTransaction#delete(LogicalDatastoreType, InstanceIdentifier)
76      *
77      * @param path The path to delete.
78      */
79     void delete(InstanceIdentifier<?> path);
80 }