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 org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
12 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec.Decoded;
13 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
14 import org.opendaylight.controller.sal.core.spi.data.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.model.api.SchemaContext;
20 * MergeModification stores all the parameters required to merge data into the specified path
22 public class MergeModification extends WriteModification {
24 public MergeModification(YangInstanceIdentifier path, NormalizedNode data,
25 SchemaContext schemaContext) {
26 super(path, data, schemaContext);
30 public void apply(DOMStoreWriteTransaction transaction) {
31 transaction.merge(path, data);
34 public static MergeModification fromSerializable(Object serializable, SchemaContext schemaContext) {
35 PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
36 Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
37 return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);