Merge "BUG-2254 Make runtime rpcs in config subsystem/netconf handle context-instance...
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / DataExists.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 DataExists implements SerializableMessage{
16
17     public static final Class<ShardTransactionMessages.DataExists> SERIALIZABLE_CLASS =
18             ShardTransactionMessages.DataExists.class;
19
20     private final YangInstanceIdentifier path;
21
22     public DataExists(final YangInstanceIdentifier path) {
23         this.path = path;
24     }
25
26     public YangInstanceIdentifier getPath() {
27         return path;
28     }
29
30     @Override public Object toSerializable() {
31         return ShardTransactionMessages.DataExists.newBuilder()
32             .setInstanceIdentifierPathArguments(
33                 InstanceIdentifierUtils.toSerializable(path)).build();
34     }
35
36     public static DataExists fromSerializable(final Object serializable){
37         ShardTransactionMessages.DataExists o = (ShardTransactionMessages.DataExists) serializable;
38         return new DataExists(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()));
39     }
40
41 }