Merge "Moved legacy Notification implementation to compat package."
[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 com.google.common.annotations.Beta;
11 import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
12 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
13
14 /**
15  * Public utility class for instantiating snapshot-backed transactions.
16  */
17 @Beta
18 public final class SnapshotBackedTransactions {
19     private SnapshotBackedTransactions() {
20         throw new UnsupportedOperationException("Utility class");
21     }
22
23     /**
24      * Creates a new read-only transaction.
25      *
26      * @param identifier Transaction Identifier
27      * @param debug Enable transaction debugging
28      * @param snapshot Snapshot which will be modified.
29      */
30     public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot) {
31         return new SnapshotBackedReadTransaction<T>(identifier, debug, snapshot);
32     }
33
34     /**
35      * Creates a new read-write transaction.
36      *
37      * @param identifier transaction Identifier
38      * @param debug Enable transaction debugging
39      * @param snapshot Snapshot which will be modified.
40      * @param readyImpl Implementation of ready method.
41      */
42     public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier, final boolean debug,
43             final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
44         return new SnapshotBackedReadWriteTransaction<T>(identifier, debug, snapshot, readyImpl);
45     }
46
47     /**
48      * Creates a new write-only transaction.
49      *
50      * @param identifier transaction Identifier
51      * @param debug Enable transaction debugging
52      * @param snapshot Snapshot which will be modified.
53      * @param readyImpl Implementation of ready method.
54      */
55     public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug,
56             final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
57         return new SnapshotBackedWriteTransaction<T>(identifier, debug, snapshot, readyImpl);
58     }
59 }