Fixup checkstyle
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / DeleteModification.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 package org.opendaylight.controller.cluster.datastore.modification;
9
10 import java.io.IOException;
11 import java.io.ObjectInput;
12 import java.io.ObjectOutput;
13 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
14 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
15 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
18 import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
19 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
20
21 /**
22  * DeleteModification store all the parameters required to delete a path from the data tree.
23  */
24 @Deprecated(since = "9.0.0", forRemoval = true)
25 public final class DeleteModification extends AbstractModification {
26     @java.io.Serial
27     private static final long serialVersionUID = 1L;
28
29     public DeleteModification() {
30         this(DataStoreVersions.CURRENT_VERSION);
31     }
32
33     public DeleteModification(final short version) {
34         super(version);
35     }
36
37     public DeleteModification(final YangInstanceIdentifier path) {
38         super(path);
39     }
40
41     DeleteModification(final short version, final YangInstanceIdentifier path) {
42         super(version, path);
43     }
44
45     @Override
46     public void apply(final DOMStoreWriteTransaction transaction) {
47         transaction.delete(getPath());
48     }
49
50     @Override
51     public void apply(final DataTreeModification transaction) {
52         transaction.delete(getPath());
53     }
54
55     @Override
56     public byte getType() {
57         return DELETE;
58     }
59
60     @Override
61     public void readExternal(final ObjectInput in) throws IOException {
62         setPath(SerializationUtils.readPath(in));
63     }
64
65     @Override
66     public void writeExternal(final ObjectOutput out) throws IOException {
67         SerializationUtils.writePath(out, getPath());
68     }
69
70     @Override
71     public void writeTo(final NormalizedNodeDataOutput out) throws IOException {
72         out.writeYangInstanceIdentifier(getPath());
73     }
74
75     public static DeleteModification fromStream(final NormalizedNodeDataInput in, final short version)
76             throws IOException {
77         return new DeleteModification(version, in.readYangInstanceIdentifier());
78     }
79 }