Switch CompositeModification to bypass thread-local streams
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / MergeModification.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 org.opendaylight.controller.cluster.datastore.DataStoreVersions;
13 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
14 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
18
19 /**
20  * MergeModification stores all the parameters required to merge data into the specified path.
21  */
22 public class MergeModification extends WriteModification {
23     private static final long serialVersionUID = 1L;
24
25     public MergeModification() {
26         this(DataStoreVersions.CURRENT_VERSION);
27     }
28
29     public MergeModification(final short version) {
30         super(version);
31     }
32
33     public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
34         super(path, data);
35     }
36
37     MergeModification(final short version, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
38         super(version, path, data);
39     }
40
41     @Override
42     public void apply(final DOMStoreWriteTransaction transaction) {
43         transaction.merge(getPath(), getData());
44     }
45
46     @Override
47     public void apply(final DataTreeModification transaction) {
48         transaction.merge(getPath(), getData());
49     }
50
51     @Override
52     public byte getType() {
53         return MERGE;
54     }
55
56     public static MergeModification fromStream(final NormalizedNodeDataInput in, final short version)
57             throws IOException {
58         final NormalizedNode<?, ?> node = in.readNormalizedNode();
59         final YangInstanceIdentifier path = in.readYangInstanceIdentifier();
60         return new MergeModification(version, path, node);
61     }
62 }

©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.