Merge "Fix NoSuchElementException thrown when transaction is empty"
[controller.git] / opendaylight / md-sal / sal-inmemory-datastore / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / DOMStoreTransactionChainImpl.java
1 /*
2  * Copyright (c) 2014 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.md.sal.dom.store.impl;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.sal.core.spi.data.AbstractSnapshotBackedTransactionChain;
12 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
13 import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransaction;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
16
17 final class DOMStoreTransactionChainImpl extends AbstractSnapshotBackedTransactionChain<String> {
18     private final InMemoryDOMDataStore store;
19
20     DOMStoreTransactionChainImpl(final InMemoryDOMDataStore store) {
21         this.store = Preconditions.checkNotNull(store);
22     }
23
24     @Override
25     protected DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<String> tx, final DataTreeModification modification) {
26         return new ChainedTransactionCommitImpl(store, tx, modification, this);
27     }
28
29     @Override
30     protected DataTreeSnapshot takeSnapshot() {
31         return store.takeSnapshot();
32     }
33
34     @Override
35     protected String nextTransactionIdentifier() {
36         return store.nextIdentifier();
37     }
38
39     @Override
40     protected boolean getDebugTransactions() {
41         return store.getDebugTransactions();
42     }
43
44     void transactionCommited(final SnapshotBackedWriteTransaction<String> transaction) {
45         super.onTransactionCommited(transaction);
46     }
47 }