057028c469416df2767a067ef5e36e4256babd35
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / PrimaryNotFound.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 com.google.common.base.Preconditions;
12 import org.opendaylight.controller.protobuff.messages.shard.ShardManagerMessages;
13
14 public class PrimaryNotFound implements SerializableMessage {
15   public static final Class SERIALIZABLE_CLASS = ShardManagerMessages.PrimaryNotFound.class;
16
17     private final String shardName;
18
19     public PrimaryNotFound(String shardName){
20
21         Preconditions.checkNotNull(shardName, "shardName should not be null");
22
23         this.shardName = shardName;
24     }
25
26     @Override
27     public boolean equals(Object o) {
28         if (this == o) return true;
29         if (o == null || getClass() != o.getClass()) return false;
30
31         PrimaryNotFound that = (PrimaryNotFound) o;
32
33         if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) return false;
34
35         return true;
36     }
37
38     @Override
39     public int hashCode() {
40         return shardName != null ? shardName.hashCode() : 0;
41     }
42
43   @Override
44   public Object toSerializable() {
45     return ShardManagerMessages.PrimaryNotFound.newBuilder().setShardName(shardName).build();
46   }
47
48   public static PrimaryNotFound fromSerializable(Object message){
49     return new PrimaryNotFound(((ShardManagerMessages.PrimaryNotFound)message).getShardName());
50   }
51 }

©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.