+
+ private Object writeReplace() {
+ return new Proxy(this);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("rpc", rpc)
+ .add("normalizedNode", inputNormalizedNode)
+ .toString();
+ }
+
+ private static class Proxy implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ private ExecuteRpc executeRpc;
+
+ // 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 ExecuteRpc executeRpc) {
+ this.executeRpc = executeRpc;
+ }
+
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ // FIXME: QName is a WritableObject
+ out.writeObject(executeRpc.getRpc());
+ SerializationUtils.writeNormalizedNode(out, executeRpc.getInputNormalizedNode());
+ }
+
+ @Override
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+ // FIXME: QName is a WritableObject
+ QName qname = (QName) in.readObject();
+ executeRpc = new ExecuteRpc(SerializationUtils.readNormalizedNode(in).orElse(null), qname);
+ }
+
+ private Object readResolve() {
+ return executeRpc;
+ }
+ }