atomic-storage: remove type dependency at segment level I/O
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / AbstractReadTransactionRequest.java
1 /*
2  * Copyright (c) 2016, 2017 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.access.commands;
9
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;
15
16 /**
17  * Abstract base class for {@link TransactionRequest}s accessing transaction state without modifying it.
18  *
19  * <p>
20  * This class is visible outside of this package for the purpose of allowing common instanceof checks
21  * and simplified codepaths.
22  *
23  * @author Robert Varga
24  *
25  * @param <T> Message type
26  */
27 @Beta
28 public abstract class AbstractReadTransactionRequest<T extends AbstractReadTransactionRequest<T>>
29         extends TransactionRequest<T> {
30     private static final long serialVersionUID = 1L;
31
32     private final boolean snapshotOnly;
33
34     AbstractReadTransactionRequest(final TransactionIdentifier identifier, final long sequence, final ActorRef replyTo,
35         final boolean snapshotOnly) {
36         super(identifier, sequence, replyTo);
37         this.snapshotOnly = snapshotOnly;
38     }
39
40     AbstractReadTransactionRequest(final T request, final ABIVersion version) {
41         super(request, version);
42         this.snapshotOnly = request.isSnapshotOnly();
43     }
44
45     public final boolean isSnapshotOnly() {
46         return snapshotOnly;
47     }
48
49     @Override
50     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
51         return super.addToStringAttributes(toStringHelper).add("snapshotOnly", snapshotOnly);
52     }
53
54     @Override
55     protected abstract AbstractReadTransactionRequestProxyV1<T> externalizableProxy(ABIVersion version);
56 }