DefaultPayload implements Payload { public static Payload create(CharSequence data) { return create(StandardCharsets.UTF_8.encode(CharBuffer.wrap(data)), null); } private  DefaultPayload(ByteBuffer data, @Nullable ByteBuffer metadata); static Payload create(CharSequence data); static Payload create(CharSequence data, @Nullable CharSequence metadata); static Payload create(CharSequence data, Charset dataCharset); static Payload create(
      CharSequence data,
      Charset dataCharset,
      @Nullable CharSequence metadata,
      Charset metadataCharset); static Payload create(byte[] data); static Payload create(byte[] data, @Nullable byte[] metadata); static Payload create(ByteBuffer data); static Payload create(ByteBuffer data, @Nullable ByteBuffer metadata); static Payload create(ByteBuf data); static Payload create(ByteBuf data, @Nullable ByteBuf metadata); static Payload create(Payload payload); @Override boolean hasMetadata(); @Override ByteBuf sliceMetadata(); @Override ByteBuf sliceData(); @Override ByteBuffer getMetadata(); @Override ByteBuffer getData(); @Override ByteBuf data(); @Override ByteBuf metadata(); @Override int refCnt(); @Override DefaultPayload retain(); @Override DefaultPayload retain(int increment); @Override DefaultPayload touch(); @Override DefaultPayload touch(Object hint); @Override boolean release(); @Override boolean release(int decrement); static final ByteBuffer EMPTY_BUFFER; }
@Test public void testReuse() { Payload p = DefaultPayload.create(DATA_VAL, METADATA_VAL); assertDataAndMetadata(p, DATA_VAL, METADATA_VAL); assertDataAndMetadata(p, DATA_VAL, METADATA_VAL); }
@Test public void staticMethods() { assertDataAndMetadata(DefaultPayload.create(DATA_VAL, METADATA_VAL), DATA_VAL, METADATA_VAL); assertDataAndMetadata(DefaultPayload.create(DATA_VAL), DATA_VAL, null); }