Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / DataExistsReply.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 java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15
16 public class DataExistsReply extends VersionedExternalizableMessage {
17     private static final long serialVersionUID = 1L;
18
19     private boolean exists;
20
21     public DataExistsReply() {
22     }
23
24     public DataExistsReply(final boolean exists, final short version) {
25         super(version);
26         this.exists = exists;
27     }
28
29     public boolean exists() {
30         return exists;
31     }
32
33     @Override
34     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
35         super.readExternal(in);
36         exists = in.readBoolean();
37     }
38
39     @Override
40     public void writeExternal(ObjectOutput out) throws IOException {
41         super.writeExternal(out);
42         out.writeBoolean(exists);
43     }
44
45     public static DataExistsReply fromSerializable(final Object serializable) {
46         Preconditions.checkArgument(serializable instanceof DataExistsReply);
47         return (DataExistsReply)serializable;
48     }
49
50     public static boolean isSerializedType(Object message) {
51         return message instanceof DataExistsReply;
52     }
53 }