Fix AbstractTransactionContext field visibility
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / AbstractTransactionContext.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.cluster.datastore;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.List;
14 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
15 import scala.concurrent.Future;
16
17 abstract class AbstractTransactionContext implements TransactionContext {
18
19     private final List<Future<Object>> recordedOperationFutures = new ArrayList<>();
20     private final TransactionIdentifier identifier;
21
22     protected AbstractTransactionContext(TransactionIdentifier identifier) {
23         this.identifier = identifier;
24     }
25
26     @Override
27     public final void copyRecordedOperationFutures(Collection<Future<Object>> target) {
28         target.addAll(recordedOperationFutures);
29     }
30
31     protected final TransactionIdentifier getIdentifier() {
32         return identifier;
33     }
34
35     protected final Collection<Future<Object>> copyRecordedOperationFutures() {
36         return ImmutableList.copyOf(recordedOperationFutures);
37     }
38
39     protected final int recordedOperationCount() {
40         return recordedOperationFutures.size();
41     }
42
43     protected final void recordOperationFuture(Future<Object> future) {
44         recordedOperationFutures.add(future);
45     }
46 }