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