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
8 package org.opendaylight.netconf.topology.singleton.messages.rpc;
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.io.Serializable;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
17 import org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 public class InvokeRpcMessage implements Serializable {
21 private static final long serialVersionUID = 1L;
23 private final SchemaPathMessage schemaPathMessage;
24 private final NormalizedNodeMessage normalizedNodeMessage;
26 public InvokeRpcMessage(final SchemaPathMessage schemaPathMessage,
27 final @Nullable NormalizedNodeMessage normalizedNodeMessage) {
28 this.schemaPathMessage = schemaPathMessage;
29 this.normalizedNodeMessage = normalizedNodeMessage;
32 private SchemaPathMessage getSchemaPathMessage() {
33 return schemaPathMessage;
36 public SchemaPath getSchemaPath() {
37 return schemaPathMessage.getSchemaPath();
41 public @Nullable NormalizedNodeMessage getNormalizedNodeMessage() {
42 return normalizedNodeMessage;
45 private Object writeReplace() {
46 return new Proxy(this);
50 public String toString() {
51 return "InvokeRpcMessage [schemaPathMessage=" + schemaPathMessage + ", normalizedNodeMessage="
52 + normalizedNodeMessage + "]";
55 private static class Proxy implements Externalizable {
56 private static final long serialVersionUID = 2L;
58 private InvokeRpcMessage invokeRpcMessage;
60 @SuppressWarnings("checkstyle:RedundantModifier")
62 //due to Externalizable
65 Proxy(final InvokeRpcMessage invokeRpcMessage) {
66 this.invokeRpcMessage = invokeRpcMessage;
70 public void writeExternal(final ObjectOutput out) throws IOException {
71 out.writeObject(invokeRpcMessage.getSchemaPathMessage());
72 out.writeObject(invokeRpcMessage.getNormalizedNodeMessage());
76 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
77 invokeRpcMessage = new InvokeRpcMessage((SchemaPathMessage) in.readObject(),
78 (NormalizedNodeMessage) in.readObject());
81 private Object readResolve() {
82 return invokeRpcMessage;