2 * Copyright (c) 2016 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.access.commands;
10 import akka.actor.ActorRef;
11 import com.google.common.annotations.Beta;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.collect.ImmutableList;
14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15 import java.util.List;
16 import java.util.Optional;
17 import org.opendaylight.controller.cluster.access.ABIVersion;
18 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
21 * A transaction request to apply a particular set of operations on top of the current transaction. This message is
22 * used to also finish a transaction by specifying a {@link PersistenceProtocol}.
24 * @author Robert Varga
27 public final class ModifyTransactionRequest extends TransactionRequest<ModifyTransactionRequest> {
28 private static final long serialVersionUID = 1L;
30 @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
31 + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
32 + "aren't serialized. FindBugs does not recognize this.")
33 private final List<TransactionModification> modifications;
34 private final PersistenceProtocol protocol;
36 ModifyTransactionRequest(final TransactionIdentifier target, final long sequence, final ActorRef replyTo,
37 final List<TransactionModification> modifications, final PersistenceProtocol protocol) {
38 super(target, sequence, replyTo);
39 this.modifications = ImmutableList.copyOf(modifications);
40 this.protocol = protocol;
43 public Optional<PersistenceProtocol> getPersistenceProtocol() {
44 return Optional.ofNullable(protocol);
47 public List<TransactionModification> getModifications() {
52 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
53 return super.addToStringAttributes(toStringHelper).add("operations", modifications).add("protocol", protocol);
57 protected ModifyTransactionRequestProxyV1 externalizableProxy(final ABIVersion version) {
58 return new ModifyTransactionRequestProxyV1(this);
62 protected ModifyTransactionRequest cloneAsVersion(final ABIVersion version) {