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.rpc;
11 import java.io.Externalizable;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import java.io.Serializable;
16 import javax.annotation.Nullable;
17 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
18 import org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 public class InvokeRpcMessage implements Serializable {
22 private static final long serialVersionUID = 1L;
24 private final SchemaPathMessage schemaPathMessage;
25 private final NormalizedNodeMessage normalizedNodeMessage;
27 public InvokeRpcMessage(final SchemaPathMessage schemaPathMessage,
28 @Nullable final NormalizedNodeMessage normalizedNodeMessage) {
29 this.schemaPathMessage = schemaPathMessage;
30 this.normalizedNodeMessage = normalizedNodeMessage;
33 private SchemaPathMessage getSchemaPathMessage() {
34 return schemaPathMessage;
37 public SchemaPath getSchemaPath() {
38 return schemaPathMessage.getSchemaPath();
42 public NormalizedNodeMessage getNormalizedNodeMessage() {
43 return normalizedNodeMessage;
46 private Object writeReplace() {
47 return new Proxy(this);
51 public String toString() {
52 return "InvokeRpcMessage [schemaPathMessage=" + schemaPathMessage + ", normalizedNodeMessage="
53 + normalizedNodeMessage + "]";
56 private static class Proxy implements Externalizable {
57 private static final long serialVersionUID = 2L;
59 private InvokeRpcMessage invokeRpcMessage;
61 @SuppressWarnings("checkstyle:RedundantModifier")
63 //due to Externalizable
66 Proxy(final InvokeRpcMessage invokeRpcMessage) {
67 this.invokeRpcMessage = invokeRpcMessage;
71 public void writeExternal(final ObjectOutput out) throws IOException {
72 out.writeObject(invokeRpcMessage.getSchemaPathMessage());
73 out.writeObject(invokeRpcMessage.getNormalizedNodeMessage());
77 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
78 invokeRpcMessage = new InvokeRpcMessage((SchemaPathMessage) in.readObject(),
79 (NormalizedNodeMessage) in.readObject());
82 private Object readResolve() {
83 return invokeRpcMessage;