69502837bcc6c114a1daa98986006ed0bd206aab
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / PrimaryFound.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.shard.ShardManagerMessages;
12
13 public class PrimaryFound implements SerializableMessage {
14   public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryFound.class;
15   private final String primaryPath;
16
17   public PrimaryFound(String primaryPath) {
18     this.primaryPath = primaryPath;
19   }
20
21   public String getPrimaryPath() {
22     return primaryPath;
23   }
24
25   @Override
26   public boolean equals(Object o) {
27     if (this == o) return true;
28     if (o == null || getClass() != o.getClass()) return false;
29
30     PrimaryFound that = (PrimaryFound) o;
31
32     if (!primaryPath.equals(that.primaryPath)) return false;
33
34     return true;
35   }
36
37   @Override
38   public int hashCode() {
39     return primaryPath.hashCode();
40   }
41
42   @Override
43   public String toString() {
44     return "PrimaryFound{" +
45             "primaryPath='" + primaryPath + '\'' +
46             '}';
47   }
48
49
50   @Override
51   public Object toSerializable() {
52     return  ShardManagerMessages.PrimaryFound.newBuilder().setPrimaryPath(primaryPath).build();
53   }
54
55   public static PrimaryFound fromSerializable(Object message){
56     return new PrimaryFound(((ShardManagerMessages.PrimaryFound)message).getPrimaryPath());
57   }
58 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.