2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore;
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;
17 abstract class AbstractTransactionContext implements TransactionContext {
19 private final List<Future<Object>> recordedOperationFutures = new ArrayList<>();
20 private final TransactionIdentifier identifier;
22 protected AbstractTransactionContext(TransactionIdentifier identifier) {
23 this.identifier = identifier;
27 public final void copyRecordedOperationFutures(Collection<Future<Object>> target) {
28 target.addAll(recordedOperationFutures);
31 protected final TransactionIdentifier getIdentifier() {
35 protected final Collection<Future<Object>> copyRecordedOperationFutures() {
36 return ImmutableList.copyOf(recordedOperationFutures);
39 protected final int recordedOperationCount() {
40 return recordedOperationFutures.size();
43 protected final void recordOperationFuture(Future<Object> future) {
44 recordedOperationFutures.add(future);