/** {@inheritDoc} */ @Override public Object onReceive(@Nullable Object obj) { if (obj instanceof byte[]) { X.println(">>> Byte array received over REST: " + Arrays.toString((byte[]) obj)); BigInteger val = new BigInteger((byte[]) obj); X.println(">>> Unpacked a BigInteger from byte array received over REST: " + val); return val; } else return obj; }
/** {@inheritDoc} */ @Override public Object onSend(Object obj) { if (obj instanceof BigInteger) { X.println(">>> Creating byte array from BigInteger to send over REST: " + obj); byte[] bytes = ((BigInteger) obj).toByteArray(); X.println( ">>> Created byte array from BigInteger to send over REST: " + Arrays.toString(bytes)); return bytes; } else return obj; }