a8a3e7d071b7af89135f529523caf8215b279cb0
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / ReadData.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.cluster.datastore.messages;
10
11 import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
12 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15 public class ReadData {
16   public static final Class<ShardTransactionMessages.ReadData> SERIALIZABLE_CLASS =
17           ShardTransactionMessages.ReadData.class;
18   private final YangInstanceIdentifier path;
19
20   public ReadData(final YangInstanceIdentifier path) {
21     this.path = path;
22   }
23
24   public YangInstanceIdentifier getPath() {
25     return path;
26   }
27
28   public Object toSerializable(){
29     return ShardTransactionMessages.ReadData.newBuilder()
30         .setInstanceIdentifierPathArguments(InstanceIdentifierUtils.toSerializable(path))
31         .build();
32   }
33
34   public static ReadData fromSerializable(final Object serializable){
35     ShardTransactionMessages.ReadData o = (ShardTransactionMessages.ReadData) serializable;
36     return new ReadData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
37   }
38 }