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%2Fmodification%2FDeleteModification.java;h=267dfa8368255955ea4a549f73103259d4d990e2;hb=HEAD;hp=593f458afa314f458ad314e6af22701160810c35;hpb=0eb621d29daaf08979c356e2148e99c48458e169;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java index 593f458afa..267dfa8368 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java @@ -5,36 +5,75 @@ * 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.modification; -import org.opendaylight.controller.cluster.datastore.utils.InstanceIdentifierUtils; -import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.opendaylight.controller.cluster.datastore.DataStoreVersions; +import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput; +import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput; +import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification; /** - * DeleteModification store all the parameters required to delete a path from the data tree + * DeleteModification store all the parameters required to delete a path from the data tree. */ -public class DeleteModification extends AbstractModification { - public DeleteModification(YangInstanceIdentifier path) { - super(path); - } - - @Override - public void apply(DOMStoreWriteTransaction transaction) { - transaction.delete(path); - } - - @Override public Object toSerializable() { - return PersistentMessages.Modification.newBuilder() - .setType(this.getClass().toString()) - .setPath(InstanceIdentifierUtils.toSerializable(this.path)) - .build(); - } - - public static DeleteModification fromSerializable(Object serializable){ - PersistentMessages.Modification o = (PersistentMessages.Modification) serializable; - return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath())); +@Deprecated(since = "9.0.0", forRemoval = true) +public final class DeleteModification extends AbstractModification { + @java.io.Serial + private static final long serialVersionUID = 1L; + + public DeleteModification() { + this(DataStoreVersions.CURRENT_VERSION); + } + + public DeleteModification(final short version) { + super(version); + } + + public DeleteModification(final YangInstanceIdentifier path) { + super(path); + } + + DeleteModification(final short version, final YangInstanceIdentifier path) { + super(version, path); + } + + @Override + public void apply(final DOMStoreWriteTransaction transaction) { + transaction.delete(getPath()); + } + + @Override + public void apply(final DataTreeModification transaction) { + transaction.delete(getPath()); + } + + @Override + public byte getType() { + return DELETE; + } + + @Override + public void readExternal(final ObjectInput in) throws IOException { + setPath(SerializationUtils.readPath(in)); + } + + @Override + public void writeExternal(final ObjectOutput out) throws IOException { + SerializationUtils.writePath(out, getPath()); + } + + @Override + public void writeTo(final NormalizedNodeDataOutput out) throws IOException { + out.writeYangInstanceIdentifier(getPath()); + } + + public static DeleteModification fromStream(final NormalizedNodeDataInput in, final short version) + throws IOException { + return new DeleteModification(version, in.readYangInstanceIdentifier()); } }