Merge "Fixed for bug 1197"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CreateTransactionReply.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.protobuff.messages.transaction.ShardTransactionMessages;
12
13 public class CreateTransactionReply implements SerializableMessage {
14
15     public static final Class SERIALIZABLE_CLASS = ShardTransactionMessages.CreateTransactionReply.class;
16     private final String transactionPath;
17     private final String transactionId;
18
19     public CreateTransactionReply(String transactionPath,
20         String transactionId) {
21         this.transactionPath = transactionPath;
22         this.transactionId = transactionId;
23     }
24
25     public String getTransactionPath() {
26         return transactionPath;
27     }
28
29     public String getTransactionId() {
30         return transactionId;
31     }
32
33     public Object toSerializable(){
34         return ShardTransactionMessages.CreateTransactionReply.newBuilder()
35             .setTransactionActorPath(transactionPath)
36             .setTransactionId(transactionId)
37             .build();
38     }
39
40     public static CreateTransactionReply fromSerializable(Object serializable){
41         ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable;
42         return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId());
43     }
44
45 }