Teach NETCONF about YANG 1.1 actions in cluster topology
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / messages / ContainerNodeMessage.java
1 /*
2  * Copyright (C) 2019 Ericsson Software Technology AB. 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 package org.opendaylight.netconf.topology.singleton.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.io.Externalizable;
13 import java.io.IOException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
17 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18
19 /**
20  * Message container which holds node data {@link ContainerNode}, prepared to send between remote hosts with
21  * serialization when remote action is invoked.
22  */
23 public class ContainerNodeMessage implements Externalizable {
24     private static final long serialVersionUID = 1L;
25
26     private ContainerNode node;
27
28     public ContainerNodeMessage() {
29         // Empty Constructor Needed for Externalizable
30     }
31
32     /**
33      * Constructor for {@code ContainerNodeMessage}.
34      *
35      * @param node ContainerNode
36      */
37     public ContainerNodeMessage(final ContainerNode node) {
38         this.node = requireNonNull(node);
39     }
40
41     public ContainerNode getNode() {
42         return node;
43     }
44
45     @Override
46     public void writeExternal(final ObjectOutput out) throws IOException {
47         SerializationUtils.writeNormalizedNode(out, node);
48     }
49
50     @Override
51     public void readExternal(final ObjectInput in) throws IOException {
52         node = (ContainerNode) SerializationUtils.readNormalizedNode(in).get();
53     }
54
55     @Override
56     public String toString() {
57         return "ContainerNodeMessage [node=" + node + "]";
58     }
59 }