2 * Copyright (c) 2016 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.netconf.topology.singleton.messages;
11 import java.io.Externalizable;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 * Message which holds node data, prepared to sending between remote hosts with serialization.
22 public class NormalizedNodeMessage implements Externalizable {
23 private static final long serialVersionUID = 1L;
25 private YangInstanceIdentifier identifier = null;
26 private NormalizedNode<?, ?> node = null;
28 public NormalizedNodeMessage() {
29 // empty constructor needed for Externalizable
32 public NormalizedNodeMessage(final YangInstanceIdentifier identifier, final NormalizedNode<?, ?> node) {
33 this.identifier = identifier;
37 public YangInstanceIdentifier getIdentifier() {
41 public NormalizedNode<?, ?> getNode() {
46 public void writeExternal(final ObjectOutput out) throws IOException {
47 SerializationUtils.serializePathAndNode(getIdentifier(), node, out);
51 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
52 SerializationUtils.deserializePathAndNode(in, this, APPLIER);
55 private static final SerializationUtils.Applier<NormalizedNodeMessage> APPLIER = (instance, path, node) -> {
56 instance.identifier = path;