+ private static final long serialVersionUID = -4211279498688989245L;
+
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+ + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+ + "aren't serialized. FindBugs does not recognize this.")
+ private final NormalizedNode<?, ?> resultNormalizedNode;
+
+ public RpcResponse(final @Nullable NormalizedNode<?, ?> inputNormalizedNode) {
+ resultNormalizedNode = inputNormalizedNode;
+ }
+
+ public @Nullable NormalizedNode<?, ?> getResultNormalizedNode() {
+ return resultNormalizedNode;
+ }
+
+ private Object writeReplace() {
+ return new Proxy(this);
+ }
+
+ private static class Proxy implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ private RpcResponse rpcResponse;
+
+ // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't
+ // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
+ }
+
+ Proxy(final RpcResponse rpcResponse) {
+ this.rpcResponse = rpcResponse;
+ }
+
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ SerializationUtils.writeNormalizedNode(out, rpcResponse.getResultNormalizedNode());
+ }