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.stmt.SchemaNodeIdentifier.Absolute;
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 SchemaPathMessage getSchemaPathMessage() {
33 return schemaPathMessage;
36 public Absolute getSchemaPath() {
37 return schemaPathMessage.getSchemaPath();
40 public @Nullable NormalizedNodeMessage getNormalizedNodeMessage() {
41 return normalizedNodeMessage;
44 private Object writeReplace() {
45 return new Proxy(this);
49 public String toString() {
50 return "InvokeRpcMessage [schemaPathMessage=" + schemaPathMessage + ", normalizedNodeMessage="
51 + normalizedNodeMessage + "]";
54 private static class Proxy implements Externalizable {
55 private static final long serialVersionUID = 2L;
57 private InvokeRpcMessage invokeRpcMessage;
59 @SuppressWarnings("checkstyle:RedundantModifier")
61 //due to Externalizable
64 Proxy(final InvokeRpcMessage invokeRpcMessage) {
65 this.invokeRpcMessage = invokeRpcMessage;
69 public void writeExternal(final ObjectOutput out) throws IOException {
70 out.writeObject(invokeRpcMessage.getSchemaPathMessage());
71 out.writeObject(invokeRpcMessage.getNormalizedNodeMessage());
75 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
76 invokeRpcMessage = new InvokeRpcMessage((SchemaPathMessage) in.readObject(),
77 (NormalizedNodeMessage) in.readObject());
80 private Object readResolve() {
81 return invokeRpcMessage;