X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmessages%2FDataExistsReply.java;h=799cd8b86e3d8d2f1903a753dcdbd1e3586b9131;hb=HEAD;hp=0ea865aa07e06b8f201955d9bfcac61c27d83725;hpb=9fb1df14f2dc885fee1dce821b753cc99af6e54f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java index 0ea865aa07..799cd8b86e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataExistsReply.java @@ -5,39 +5,25 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.datastore.messages; -import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages; - -public class DataExistsReply implements SerializableMessage { - public static final Class SERIALIZABLE_CLASS = - ShardTransactionMessages.DataExistsReply.class; - - private static final DataExistsReply TRUE = new DataExistsReply(true, null); - private static final DataExistsReply FALSE = new DataExistsReply(false, null); - private static final ShardTransactionMessages.DataExistsReply SERIALIZABLE_TRUE = - ShardTransactionMessages.DataExistsReply.newBuilder().setExists(true).build(); - private static final ShardTransactionMessages.DataExistsReply SERIALIZABLE_FALSE = - ShardTransactionMessages.DataExistsReply.newBuilder().setExists(false).build(); +import com.google.common.base.Preconditions; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; - private final boolean exists; +@Deprecated(since = "9.0.0", forRemoval = true) +public class DataExistsReply extends VersionedExternalizableMessage { + private static final long serialVersionUID = 1L; - private DataExistsReply(final boolean exists, final Void dummy) { - this.exists = exists; - } + private boolean exists; - /** - * @deprecated Use {@link #create(boolean)} instead. - * @param exists - */ - @Deprecated - public DataExistsReply(final boolean exists) { - this(exists, null); + public DataExistsReply() { } - public static DataExistsReply create(final boolean exists) { - return exists ? TRUE : FALSE; + public DataExistsReply(final boolean exists, final short version) { + super(version); + this.exists = exists; } public boolean exists() { @@ -45,12 +31,23 @@ public class DataExistsReply implements SerializableMessage { } @Override - public Object toSerializable() { - return exists ? SERIALIZABLE_TRUE : SERIALIZABLE_FALSE; + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { + super.readExternal(in); + exists = in.readBoolean(); + } + + @Override + public void writeExternal(final ObjectOutput out) throws IOException { + super.writeExternal(out); + out.writeBoolean(exists); } public static DataExistsReply fromSerializable(final Object serializable) { - ShardTransactionMessages.DataExistsReply o = (ShardTransactionMessages.DataExistsReply) serializable; - return create(o.getExists()); + Preconditions.checkArgument(serializable instanceof DataExistsReply); + return (DataExistsReply)serializable; + } + + public static boolean isSerializedType(final Object message) { + return message instanceof DataExistsReply; } }