Adjust to mdsal DOM read/exists FluentFuture change
[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 com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import java.util.Optional;
14 import org.opendaylight.controller.cluster.access.ABIVersion;
15 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
16 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18
19 /**
20  * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via
21  * {@link #getData()}.
22  *
23  * @author Robert Varga
24  */
25 @Beta
26 @SuppressFBWarnings("SE_BAD_FIELD")
27 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
28         implements SliceableMessage {
29     private static final long serialVersionUID = 1L;
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 = Preconditions.checkNotNull(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 }