@Test void testEncode() throws IOException { ByteBuf buf = encoder.encode(Unpooled.directBuffer(), "", dino); assertEquals(dino, Dino.parseFrom(bufBytes(buf))); }
@Override public ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object) throws IOException { if (!(object instanceof MessageLite)) { throw new IllegalArgumentException( String.format("%s does not extend from MessageLite", object.getClass().getName())); } MessageLite msg = (MessageLite) object; try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) { msg.writeTo(stream); return buf; } }
ProtoEncoder implements Encoder { @Override public ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object) throws IOException { if (!(object instanceof MessageLite)) { throw new IllegalArgumentException( String.format("%s does not extend from MessageLite", object.getClass().getName())); } MessageLite msg = (MessageLite) object; try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) { msg.writeTo(stream); return buf; } } }
ProtoEncoder implements Encoder { @Override public ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object) throws IOException { if (!(object instanceof MessageLite)) { throw new IllegalArgumentException( String.format("%s does not extend from MessageLite", object.getClass().getName())); } MessageLite msg = (MessageLite) object; try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) { msg.writeTo(stream); return buf; } }  }
ProtoEncoder implements Encoder { @Override public ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object) throws IOException { if (!(object instanceof MessageLite)) { throw new IllegalArgumentException( String.format("%s does not extend from MessageLite", object.getClass().getName())); } MessageLite msg = (MessageLite) object; try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) { msg.writeTo(stream); return buf; } }  @Override CharSequence mediaType(); @Override ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object); }
ProtoEncoder implements Encoder { @Override public ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object) throws IOException { if (!(object instanceof MessageLite)) { throw new IllegalArgumentException( String.format("%s does not extend from MessageLite", object.getClass().getName())); } MessageLite msg = (MessageLite) object; try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) { msg.writeTo(stream); return buf; } }  @Override CharSequence mediaType(); @Override ByteBuf encode(ByteBuf buf, CharSequence acceptCharset, Object object);  }