2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.datastore.modification;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
14 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
15 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
16 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 * MergeModification stores all the parameters required to merge data into the specified path
23 public class MergeModification extends WriteModification {
24 private static final long serialVersionUID = 1L;
26 public MergeModification() {
29 public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
34 public void apply(final DOMStoreWriteTransaction transaction) {
35 transaction.merge(getPath(), getData());
39 public byte getType() {
44 public static MergeModification fromSerializable(final Object serializable) {
45 PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
46 Decoded decoded = new NormalizedNodeToNodeCodec(null).decode(o.getPath(), o.getData());
47 return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode());
50 public static MergeModification fromStream(ObjectInput in) throws ClassNotFoundException, IOException {
51 MergeModification mod = new MergeModification();