2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.messages;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
15 import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
16 import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
17 import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 * @deprecated Replaced by BatchedModifications.
24 public class DeleteData extends VersionedExternalizableMessage {
25 private static final long serialVersionUID = 1L;
27 public static final Class<DeleteData> SERIALIZABLE_CLASS = DeleteData.class;
29 private YangInstanceIdentifier path;
34 public DeleteData(final YangInstanceIdentifier path, short version) {
39 public YangInstanceIdentifier getPath() {
44 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
45 super.readExternal(in);
46 path = SerializationUtils.deserializePath(in);
50 public void writeExternal(ObjectOutput out) throws IOException {
51 super.writeExternal(out);
52 SerializationUtils.serializePath(path, out);
56 public Object toSerializable() {
57 if(getVersion() >= DataStoreVersions.LITHIUM_VERSION) {
60 // To base or R1 Helium version
61 return ShardTransactionMessages.DeleteData.newBuilder().setInstanceIdentifierPathArguments(
62 InstanceIdentifierUtils.toSerializable(path)).build();
66 public static DeleteData fromSerializable(final Object serializable) {
67 if(serializable instanceof DeleteData) {
68 return (DeleteData) serializable;
70 // From base or R1 Helium version
71 ShardTransactionMessages.DeleteData o = (ShardTransactionMessages.DeleteData) serializable;
72 return new DeleteData(InstanceIdentifierUtils.fromSerializable(o.getInstanceIdentifierPathArguments()),
73 DataStoreVersions.HELIUM_2_VERSION);
77 public static boolean isSerializedType(Object message) {
78 return SERIALIZABLE_CLASS.isInstance(message) ||
79 message instanceof ShardTransactionMessages.DeleteData;