Bug 7449: Slice ReadTransactionSuccess response
[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.Optional;
12 import com.google.common.base.Preconditions;
13 import org.opendaylight.controller.cluster.access.ABIVersion;
14 import org.opendaylight.controller.cluster.access.concepts.SliceableMessage;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * Successful reply to an {@link ReadTransactionRequest}. It indicates presence of requested data via
20  * {@link #getData()}.
21  *
22  * @author Robert Varga
23  */
24 @Beta
25 public final class ReadTransactionSuccess extends TransactionSuccess<ReadTransactionSuccess>
26         implements SliceableMessage {
27     private static final long serialVersionUID = 1L;
28     private final Optional<NormalizedNode<?, ?>> data;
29
30     public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
31             final Optional<NormalizedNode<?, ?>> data) {
32         super(identifier, sequence);
33         this.data = Preconditions.checkNotNull(data);
34     }
35
36     public Optional<NormalizedNode<?, ?>> getData() {
37         return data;
38     }
39
40     @Override
41     protected AbstractTransactionSuccessProxy<ReadTransactionSuccess> externalizableProxy(final ABIVersion version) {
42         return new ReadTransactionSuccessProxyV1(this);
43     }
44
45     @Override
46     protected ReadTransactionSuccess cloneAsVersion(final ABIVersion version) {
47         return this;
48     }
49 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.