a82a65ea7eafcaf005e07b45cc6f6b8196c0725c
[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,
31             final DataTreeSnapshot snapshot) {
32         return new SnapshotBackedReadTransaction<>(identifier, debug, snapshot);
33     }
34
35     /**
36      * Creates a new read-write transaction.
37      *
38      * @param identifier transaction Identifier
39      * @param debug Enable transaction debugging
40      * @param snapshot Snapshot which will be modified.
41      * @param readyImpl Implementation of ready method.
42      */
43     public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier,
44             final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
45         return new SnapshotBackedReadWriteTransaction<>(identifier, debug, snapshot, readyImpl);
46     }
47
48     /**
49      * Creates a new write-only transaction.
50      *
51      * @param identifier transaction Identifier
52      * @param debug Enable transaction debugging
53      * @param snapshot Snapshot which will be modified.
54      * @param readyImpl Implementation of ready method.
55      */
56     public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug,
57             final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
58         return new SnapshotBackedWriteTransaction<>(identifier, debug, snapshot, readyImpl);
59     }
60 }