@Test void decodesJsonPassthroughByteArray() { byte[] input = "{\"hello\": true}".getBytes(StandardCharsets.UTF_8); byte[] output = RAW_JSON_TRANSCODER.decode( byte[].class, input, CodecFlags.JSON_COMPAT_FLAGS ); assertArrayEquals(input, output); }
@Override @SuppressWarnings("unchecked") public <T> T decode(final Class<T> target, final byte[] input, int flags) { if (target.isAssignableFrom(byte[].class)) { return (T) input; } else if (target.isAssignableFrom(String.class)) { return (T) new String(input, StandardCharsets.UTF_8); } else { throw new DecodingFailureException("RawJsonTranscoder can only decode into either byte[] or String!"); } }
RawJsonTranscoder implements Transcoder { @Override @SuppressWarnings("unchecked") public <T> T decode(final Class<T> target, final byte[] input, int flags) { if (target.isAssignableFrom(byte[].class)) { return (T) input; } else if (target.isAssignableFrom(String.class)) { return (T) new String(input, StandardCharsets.UTF_8); } else { throw new DecodingFailureException("RawJsonTranscoder can only decode into either byte[] or String!"); } } }
RawJsonTranscoder implements Transcoder { @Override @SuppressWarnings("unchecked") public <T> T decode(final Class<T> target, final byte[] input, int flags) { if (target.isAssignableFrom(byte[].class)) { return (T) input; } else if (target.isAssignableFrom(String.class)) { return (T) new String(input, StandardCharsets.UTF_8); } else { throw new DecodingFailureException("RawJsonTranscoder can only decode into either byte[] or String!"); } } private  RawJsonTranscoder(); }
RawJsonTranscoder implements Transcoder { @Override @SuppressWarnings("unchecked") public <T> T decode(final Class<T> target, final byte[] input, int flags) { if (target.isAssignableFrom(byte[].class)) { return (T) input; } else if (target.isAssignableFrom(String.class)) { return (T) new String(input, StandardCharsets.UTF_8); } else { throw new DecodingFailureException("RawJsonTranscoder can only decode into either byte[] or String!"); } } 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 @SuppressWarnings("unchecked") public <T> T decode(final Class<T> target, final byte[] input, int flags) { if (target.isAssignableFrom(byte[].class)) { return (T) input; } else if (target.isAssignableFrom(String.class)) { return (T) new String(input, StandardCharsets.UTF_8); } else { throw new DecodingFailureException("RawJsonTranscoder can only decode into either byte[] or String!"); } } 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; }