Merge "Remove l2switch sample"
[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     private final int version;
19
20     public CreateTransactionReply(String transactionPath,
21         String transactionId) {
22         this(transactionPath, transactionId, CreateTransaction.CURRENT_VERSION);
23     }
24
25     public CreateTransactionReply(String transactionPath,
26                                   String transactionId, int version) {
27         this.transactionPath = transactionPath;
28         this.transactionId = transactionId;
29         this.version = version;
30     }
31
32
33     public String getTransactionPath() {
34         return transactionPath;
35     }
36
37     public String getTransactionId() {
38         return transactionId;
39     }
40
41     public int getVersion() {
42         return version;
43     }
44
45     public Object toSerializable(){
46         return ShardTransactionMessages.CreateTransactionReply.newBuilder()
47             .setTransactionActorPath(transactionPath)
48             .setTransactionId(transactionId)
49             .setMessageVersion(version)
50             .build();
51     }
52
53     public static CreateTransactionReply fromSerializable(Object serializable){
54         ShardTransactionMessages.CreateTransactionReply o = (ShardTransactionMessages.CreateTransactionReply) serializable;
55         return new CreateTransactionReply(o.getTransactionActorPath(), o.getTransactionId(), o.getMessageVersion());
56     }
57
58 }