2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.messages;
11 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
12 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 public class ReadDataReply implements SerializableMessage{
19 private final NormalizedNode<?, ?> normalizedNode;
20 private final SchemaContext schemaContext;
21 public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.ReadDataReply.class;
22 public ReadDataReply(SchemaContext context,NormalizedNode<?, ?> normalizedNode){
24 this.normalizedNode = normalizedNode;
25 this.schemaContext = context;
28 public NormalizedNode<?, ?> getNormalizedNode() {
29 return normalizedNode;
32 public Object toSerializable(){
33 if(normalizedNode != null) {
34 return ShardTransactionMessages.ReadDataReply.newBuilder()
35 .setNormalizedNode(new NormalizedNodeToNodeCodec(schemaContext)
36 .encode(YangInstanceIdentifier.builder().build(), normalizedNode).getNormalizedNode()
39 return ShardTransactionMessages.ReadDataReply.newBuilder().build();
45 public static ReadDataReply fromSerializable(SchemaContext schemaContext,YangInstanceIdentifier id,Object serializable){
46 ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
47 return new ReadDataReply(schemaContext,new NormalizedNodeToNodeCodec(schemaContext).decode(id, o.getNormalizedNode()));