465372736bb398769d811fd217319a1f1b694328
[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.ObjectInput;
12 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
13 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
17
18 /**
19  * MergeModification stores all the parameters required to merge data into the specified path.
20  */
21 public class MergeModification extends WriteModification {
22     private static final long serialVersionUID = 1L;
23
24     public MergeModification() {
25         this(DataStoreVersions.CURRENT_VERSION);
26     }
27
28     public MergeModification(short version) {
29         super(version);
30     }
31
32     public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
33         super(path, data);
34     }
35
36     @Override
37     public void apply(final DOMStoreWriteTransaction transaction) {
38         transaction.merge(getPath(), getData());
39     }
40
41     @Override
42     public void apply(final DataTreeModification transaction) {
43         transaction.merge(getPath(), getData());
44     }
45
46     @Override
47     public byte getType() {
48         return MERGE;
49     }
50
51     public static MergeModification fromStream(ObjectInput in, short version) {
52         MergeModification mod = new MergeModification(version);
53         mod.readExternal(in);
54         return mod;
55     }
56 }

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