Refactor snapshot code
[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
13 public class PrimaryNotFound implements SerializableMessage {
14   public static final Class<PrimaryNotFound> SERIALIZABLE_CLASS = PrimaryNotFound.class;
15
16     private final String shardName;
17
18     public PrimaryNotFound(final String shardName){
19
20         Preconditions.checkNotNull(shardName, "shardName should not be null");
21
22         this.shardName = shardName;
23     }
24
25     @Override
26     public boolean equals(final Object o) {
27         if (this == o) {
28             return true;
29         }
30         if (o == null || getClass() != o.getClass()) {
31             return false;
32         }
33
34         PrimaryNotFound that = (PrimaryNotFound) o;
35
36         if (shardName != null ? !shardName.equals(that.shardName) : that.shardName != null) {
37             return false;
38         }
39
40         return true;
41     }
42
43     @Override
44     public int hashCode() {
45         return shardName != null ? shardName.hashCode() : 0;
46     }
47
48   @Override
49   public Object toSerializable() {
50     return this;
51   }
52
53   public static PrimaryNotFound fromSerializable(final Object message){
54     return (PrimaryNotFound) message;
55   }
56 }