2 * Copyright (c) 2014 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.controller.remote.rpc.messages;
10 import java.io.Externalizable;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 public class RpcResponse extends AbstractResponse<NormalizedNode<?, ?>> {
19 private static final long serialVersionUID = -4211279498688989245L;
21 public RpcResponse(final @Nullable NormalizedNode<?, ?> output) {
26 Object writeReplace() {
27 return new Proxy(this);
30 private static class Proxy implements Externalizable {
31 private static final long serialVersionUID = 1L;
33 private RpcResponse rpcResponse;
35 // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
36 // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
37 @SuppressWarnings("checkstyle:RedundantModifier")
41 Proxy(final RpcResponse rpcResponse) {
42 this.rpcResponse = rpcResponse;
46 public void writeExternal(final ObjectOutput out) throws IOException {
47 SerializationUtils.writeNormalizedNode(out, rpcResponse.getOutput());
51 public void readExternal(final ObjectInput in) throws IOException {
52 rpcResponse = new RpcResponse(SerializationUtils.readNormalizedNode(in).orElse(null));
55 private Object readResolve() {