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.SliceableMessage;
19 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
22 * A transaction request to apply a particular set of operations on top of the current transaction. This message is
23 * used to also finish a transaction by specifying a {@link PersistenceProtocol}.
25 * @author Robert Varga
28 public final class ModifyTransactionRequest extends TransactionRequest<ModifyTransactionRequest>
29 implements SliceableMessage {
30 private static final long serialVersionUID = 1L;
32 @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
33 + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
34 + "aren't serialized. FindBugs does not recognize this.")
35 private final List<TransactionModification> modifications;
36 private final PersistenceProtocol protocol;
38 ModifyTransactionRequest(final TransactionIdentifier target, final long sequence, final ActorRef replyTo,
39 final List<TransactionModification> modifications, final PersistenceProtocol protocol) {
40 super(target, sequence, replyTo);
41 this.modifications = ImmutableList.copyOf(modifications);
42 this.protocol = protocol;
45 public Optional<PersistenceProtocol> getPersistenceProtocol() {
46 return Optional.ofNullable(protocol);
49 public List<TransactionModification> getModifications() {
54 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
55 return super.addToStringAttributes(toStringHelper).add("modifications", modifications.size())
56 .add("protocol", protocol);
60 protected ModifyTransactionRequestProxyV1 externalizableProxy(final ABIVersion version) {
61 return new ModifyTransactionRequestProxyV1(this);
65 protected ModifyTransactionRequest cloneAsVersion(final ABIVersion version) {