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