@Test public void test_deserialize_type_right() { for (Class<?> ifce : String.class.getInterfaces()) { assertThat(codec.deserialize("", ifce), is(equalTo(""))); } for (Class<?> c = String.class.getSuperclass(); c != null; c = c.getSuperclass()) { assertThat(codec.deserialize("", c), is(equalTo(""))); } assertThat(codec.deserialize("", byte[].class), is(equalTo(new byte[0]))); }
@Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); @Override String serialize(Object o); @Override T deserialize(String response, Class<T> target); @Override String toString(); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); @Override String serialize(Object o); @Override T deserialize(String response, Class<T> target); @Override String toString();  }