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 {
23 private static final long serialVersionUID = 1L;
25 public MergeModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data,
26 final SchemaContext schemaContext) {
27 super(path, data, schemaContext);
31 public void apply(final DOMStoreWriteTransaction transaction) {
32 transaction.merge(path, data);
35 public static MergeModification fromSerializable(final Object serializable, final SchemaContext schemaContext) {
36 PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
37 Decoded decoded = new NormalizedNodeToNodeCodec(schemaContext).decode(o.getPath(), o.getData());
38 return new MergeModification(decoded.getDecodedPath(), decoded.getDecodedNode(), schemaContext);