import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
-import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
-import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
+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.api.schema.tree.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 {
private static final long serialVersionUID = 1L;
this(DataStoreVersions.CURRENT_VERSION);
}
- public DeleteModification(short version) {
+ public DeleteModification(final short version) {
super(version);
}
- public DeleteModification(YangInstanceIdentifier path) {
+ public DeleteModification(final YangInstanceIdentifier path) {
super(path);
}
+ DeleteModification(final short version, final YangInstanceIdentifier path) {
+ super(version, path);
+ }
+
@Override
- public void apply(DOMStoreWriteTransaction transaction) {
+ public void apply(final DOMStoreWriteTransaction transaction) {
transaction.delete(getPath());
}
@Override
- public void apply(DataTreeModification transaction) {
+ public void apply(final DataTreeModification transaction) {
transaction.delete(getPath());
}
}
@Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- setPath(SerializationUtils.deserializePath(in));
+ public void readExternal(final ObjectInput in) throws IOException {
+ setPath(SerializationUtils.readPath(in));
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
- SerializationUtils.serializePath(getPath(), out);
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ SerializationUtils.writePath(out, getPath());
}
@Override
- @Deprecated
- public Object toSerializable() {
- return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString())
- .setPath(InstanceIdentifierUtils.toSerializable(getPath())).build();
+ public void writeTo(final NormalizedNodeDataOutput out) throws IOException {
+ out.writeYangInstanceIdentifier(getPath());
}
@Deprecated
- public static DeleteModification fromSerializable(Object serializable) {
- PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
- return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath()));
- }
-
- public static DeleteModification fromStream(ObjectInput in, short version)
- throws ClassNotFoundException, IOException {
+ public static DeleteModification fromStream(final ObjectInput in, final short version) {
DeleteModification mod = new DeleteModification(version);
- mod.readExternal(in);
+ try {
+ mod.readExternal(in);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Error deserializing DeleteModification", e);
+ }
return mod;
}
+
+ public static DeleteModification fromStream(final NormalizedNodeDataInput in, final short version)
+ throws IOException {
+ return new DeleteModification(version, in.readYangInstanceIdentifier());
+ }
}