Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ReadTransactionSuccess.java
1 /*
2  * Copyright (c) 2016 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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
14 import java.util.Optional;
15 import org.opendaylight.controller.cluster.access.ABIVersion;
16 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
17 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19
20 /**
21  * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via
22  * {@link #getData()}.
23  *
24  * @author Robert Varga
25  */
26 @Beta
27 @SuppressFBWarnings("SE_BAD_FIELD")
28 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
29         implements SliceableMessage {
30     private static final long serialVersionUID = 1L;
31     private final Optional<NormalizedNode<?, ?>> data;
32
33     public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
34             final Optional<NormalizedNode<?, ?>> data) {
35         super(identifier, sequence);
36         this.data = requireNonNull(data);
37     }
38
39     public Optional<NormalizedNode<?, ?>> getData() {
40         return data;
41     }
42
43     @Override
44     protected AbstractTransactionSuccessProxy<ReadTransactionSuccess> externalizableProxy(final ABIVersion version) {
45         return new ReadTransactionSuccessProxyV1(this);
46     }
47
48     @Override
49     protected ReadTransactionSuccess cloneAsVersion(final ABIVersion version) {
50         return this;
51     }
52 }