2 * Copyright (c) 2016, 2017 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 org.opendaylight.controller.cluster.access.ABIVersion;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17 * Abstract base class for {@link TransactionRequest}s accessing transaction state without modifying it.
20 * This class is visible outside of this package for the purpose of allowing common instanceof checks
21 * and simplified codepaths.
23 * @author Robert Varga
25 * @param <T> Message type
28 public abstract class AbstractReadTransactionRequest<T extends AbstractReadTransactionRequest<T>>
29 extends TransactionRequest<T> {
30 private static final long serialVersionUID = 1L;
32 private final boolean snapshotOnly;
34 AbstractReadTransactionRequest(final TransactionIdentifier identifier, final long sequence, final ActorRef replyTo,
35 final boolean snapshotOnly) {
36 super(identifier, sequence, replyTo);
37 this.snapshotOnly = snapshotOnly;
40 AbstractReadTransactionRequest(final T request, final ABIVersion version) {
41 super(request, version);
42 this.snapshotOnly = request.isSnapshotOnly();
45 public final boolean isSnapshotOnly() {
50 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
51 return super.addToStringAttributes(toStringHelper).add("snapshotOnly", snapshotOnly);
55 protected abstract AbstractReadTransactionRequestProxyV1<T> externalizableProxy(ABIVersion version);