@Test public void test() { DataEncoder encoder = new JsonDataEncoderBuilder() .registerFallbackEncoder(ReflectiveObjectEncoder.DEFAULT) .build(); String result = encoder.encode(new Foo()); assertThat(result) .isEqualTo( "{\"string\":\"hello\",\"member\":{\"bool\":false},\"map\":{\"key\":22},\"bool\":false}"); }
@Override public void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx) throws IOException { @SuppressWarnings("unchecked") ObjectEncoder<Object> encoder = getEncoder((Class<Object>) obj.getClass()); encoder.encode(obj, ctx); }
ReflectiveObjectEncoder implements ObjectEncoder<Object> { @Override public void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx) throws IOException { @SuppressWarnings("unchecked") ObjectEncoder<Object> encoder = getEncoder((Class<Object>) obj.getClass()); encoder.encode(obj, ctx); } }
ReflectiveObjectEncoder implements ObjectEncoder<Object> { @Override public void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx) throws IOException { @SuppressWarnings("unchecked") ObjectEncoder<Object> encoder = getEncoder((Class<Object>) obj.getClass()); encoder.encode(obj, ctx); } private  ReflectiveObjectEncoder(ObjectEncoderProvider provider, boolean threadSafe);  ReflectiveObjectEncoder(boolean threadSafe); }
ReflectiveObjectEncoder implements ObjectEncoder<Object> { @Override public void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx) throws IOException { @SuppressWarnings("unchecked") ObjectEncoder<Object> encoder = getEncoder((Class<Object>) obj.getClass()); encoder.encode(obj, ctx); } private  ReflectiveObjectEncoder(ObjectEncoderProvider provider, boolean threadSafe);  ReflectiveObjectEncoder(boolean threadSafe); @Override void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx); }
ReflectiveObjectEncoder implements ObjectEncoder<Object> { @Override public void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx) throws IOException { @SuppressWarnings("unchecked") ObjectEncoder<Object> encoder = getEncoder((Class<Object>) obj.getClass()); encoder.encode(obj, ctx); } private  ReflectiveObjectEncoder(ObjectEncoderProvider provider, boolean threadSafe);  ReflectiveObjectEncoder(boolean threadSafe); @Override void encode(@NonNull Object obj, @NonNull ObjectEncoderContext ctx); @NonNull static final ReflectiveObjectEncoder DEFAULT; }