@Test void encodesJsonPassthroughByteArray() { byte[] input = "{\"hello\": true}".getBytes(StandardCharsets.UTF_8); Transcoder.EncodedValue output = RAW_JSON_TRANSCODER.encode(input); assertArrayEquals(input, output.encoded()); }
@Override public EncodedValue encode(final Object input) { if (input instanceof CommonOptions.BuiltCommonOptions || input instanceof CommonOptions) { throw InvalidArgumentException.fromMessage("No content provided, cannot " + "encode " + input.getClass().getSimpleName() + " as content!"); } if (input instanceof byte[]) { return new EncodedValue((byte[]) input, CodecFlags.JSON_COMPAT_FLAGS); } else if (input instanceof String) { return new EncodedValue(((String) input).getBytes(StandardCharsets.UTF_8), CodecFlags.JSON_COMPAT_FLAGS); } else { throw InvalidArgumentException.fromMessage("Only byte[] and String types are supported for the RawJsonTranscoder!"); } }
RawJsonTranscoder implements Transcoder { @Override public EncodedValue encode(final Object input) { if (input instanceof CommonOptions.BuiltCommonOptions || input instanceof CommonOptions) { throw InvalidArgumentException.fromMessage("No content provided, cannot " + "encode " + input.getClass().getSimpleName() + " as content!"); } if (input instanceof byte[]) { return new EncodedValue((byte[]) input, CodecFlags.JSON_COMPAT_FLAGS); } else if (input instanceof String) { return new EncodedValue(((String) input).getBytes(StandardCharsets.UTF_8), CodecFlags.JSON_COMPAT_FLAGS); } else { throw InvalidArgumentException.fromMessage("Only byte[] and String types are supported for the RawJsonTranscoder!"); } } }
RawJsonTranscoder implements Transcoder { @Override public EncodedValue encode(final Object input) { if (input instanceof CommonOptions.BuiltCommonOptions || input instanceof CommonOptions) { throw InvalidArgumentException.fromMessage("No content provided, cannot " + "encode " + input.getClass().getSimpleName() + " as content!"); } if (input instanceof byte[]) { return new EncodedValue((byte[]) input, CodecFlags.JSON_COMPAT_FLAGS); } else if (input instanceof String) { return new EncodedValue(((String) input).getBytes(StandardCharsets.UTF_8), CodecFlags.JSON_COMPAT_FLAGS); } else { throw InvalidArgumentException.fromMessage("Only byte[] and String types are supported for the RawJsonTranscoder!"); } } private  RawJsonTranscoder(); }
RawJsonTranscoder implements Transcoder { @Override public EncodedValue encode(final Object input) { if (input instanceof CommonOptions.BuiltCommonOptions || input instanceof CommonOptions) { throw InvalidArgumentException.fromMessage("No content provided, cannot " + "encode " + input.getClass().getSimpleName() + " as content!"); } if (input instanceof byte[]) { return new EncodedValue((byte[]) input, CodecFlags.JSON_COMPAT_FLAGS); } else if (input instanceof String) { return new EncodedValue(((String) input).getBytes(StandardCharsets.UTF_8), CodecFlags.JSON_COMPAT_FLAGS); } else { throw InvalidArgumentException.fromMessage("Only byte[] and String types are supported for the RawJsonTranscoder!"); } } private  RawJsonTranscoder(); @Override EncodedValue encode(final Object input); @Override @SuppressWarnings("unchecked") T decode(final Class<T> target, final byte[] input, int flags); }
RawJsonTranscoder implements Transcoder { @Override public EncodedValue encode(final Object input) { if (input instanceof CommonOptions.BuiltCommonOptions || input instanceof CommonOptions) { throw InvalidArgumentException.fromMessage("No content provided, cannot " + "encode " + input.getClass().getSimpleName() + " as content!"); } if (input instanceof byte[]) { return new EncodedValue((byte[]) input, CodecFlags.JSON_COMPAT_FLAGS); } else if (input instanceof String) { return new EncodedValue(((String) input).getBytes(StandardCharsets.UTF_8), CodecFlags.JSON_COMPAT_FLAGS); } else { throw InvalidArgumentException.fromMessage("Only byte[] and String types are supported for the RawJsonTranscoder!"); } } private  RawJsonTranscoder(); @Override EncodedValue encode(final Object input); @Override @SuppressWarnings("unchecked") T decode(final Class<T> target, final byte[] input, int flags); static RawJsonTranscoder INSTANCE; }