Deprecate all MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-dom-spi / src / main / java / org / opendaylight / controller / sal / core / spi / data / SnapshotBackedTransactions.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
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.controller.sal.core.spi.data;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction.TransactionClosePrototype;
14 import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
16
17 /**
18  * Public utility class for instantiating snapshot-backed transactions.
19  *
20  * @deprecated Use {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedTransactions} instead.
21  */
22 @Deprecated
23 @Beta
24 public final class SnapshotBackedTransactions {
25     private SnapshotBackedTransactions() {
26         throw new UnsupportedOperationException("Utility class");
27     }
28
29     /**
30      * Creates a new read-only transaction.
31      *
32      * @param identifier Transaction Identifier
33      * @param debug Enable transaction debugging
34      * @param snapshot Snapshot which will be modified.
35      * @return A new read-only transaction
36      */
37     public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug,
38             final DataTreeSnapshot snapshot) {
39         return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, null);
40     }
41
42     /**
43      * Creates a new read-only transaction.
44      *
45      * @param identifier Transaction Identifier
46      * @param debug Enable transaction debugging
47      * @param snapshot Snapshot which will be modified.
48      * @param closeImpl Implementation of close method
49      * @return A new read-only transaction
50      */
51     public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier,
52             final boolean debug, final DataTreeSnapshot snapshot, final TransactionClosePrototype<T> closeImpl) {
53         return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot, requireNonNull(closeImpl));
54     }
55
56     /**
57      * Creates a new read-write transaction.
58      *
59      * @param identifier transaction Identifier
60      * @param debug Enable transaction debugging
61      * @param snapshot Snapshot which will be modified.
62      * @param readyImpl Implementation of ready method.
63      * @return A new read-write transaction
64      */
65     public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier,
66             final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
67         return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl);
68     }
69
70     /**
71      * Creates a new write-only transaction.
72      *
73      * @param identifier transaction Identifier
74      * @param debug Enable transaction debugging
75      * @param snapshot Snapshot which will be modified.
76      * @param readyImpl Implementation of ready method.
77      * @return A new write transaction
78      */
79     public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug,
80             final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
81         return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl);
82     }
83 }