Promote cds-access-api
[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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import java.io.Serial;
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 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
25         implements SliceableMessage {
26     @Serial
27     private static final long serialVersionUID = 1L;
28
29     @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "interface-based best effort")
30     private final Optional<NormalizedNode> data;
31
32     public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
33             final Optional<NormalizedNode> data) {
34         super(identifier, sequence);
35         this.data = requireNonNull(data);
36     }
37
38     public Optional<NormalizedNode> getData() {
39         return data;
40     }
41
42     @Override
43     protected AbstractTransactionSuccessProxy<ReadTransactionSuccess> externalizableProxy(final ABIVersion version) {
44         return new ReadTransactionSuccessProxyV1(this);
45     }
46
47     @Override
48     protected ReadTransactionSuccess cloneAsVersion(final ABIVersion version) {
49         return this;
50     }
51 }