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

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.