ByteBufHttpData implements HttpData, ResourceLeakHint { @Override public boolean equals(Object obj) { if (!(obj instanceof HttpData)) { return false; } if (obj == this) { return true; } final HttpData that = (HttpData) obj; if (buf.readableBytes() != that.length()) { return false; } return ByteBufUtil.equals(buf, that.byteBuf()); } ByteBufHttpData(ByteBuf buf, boolean pooled); private  ByteBufHttpData(ByteBuf buf, int flags, @Nullable byte[] array); @Override byte[] array(); @Override int length(); @Override String toString(Charset charset); @Override String toString(); @Override String toHintString(); @Override InputStream toInputStream(); @Override boolean isEndOfStream(); @Override ByteBufHttpData withEndOfStream(boolean endOfStream); @Override boolean isPooled(); @Override ByteBuf byteBuf(ByteBufAccessMode mode); @Override ByteBuf byteBuf(int offset, int length, ByteBufAccessMode mode); @Override void touch(@Nullable Object hint); @Override void close(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test void equals() { final HttpData a = new ByteBufHttpData(Unpooled.directBuffer().writeInt(0x01020304), true); final HttpData b = new ByteBufHttpData(Unpooled.directBuffer().writeInt(0x01020304), true); final HttpData c = new ByteBufHttpData(Unpooled.directBuffer().writeMedium(0x010203), true); final HttpData d = new ByteBufHttpData(Unpooled.directBuffer().writeInt(0x04050607), true); final HttpData arrayData = new ByteArrayHttpData(new byte[] { 1, 2, 3, 4 }); assertThat(a).isEqualTo(a); assertThat(a).isEqualTo(b); assertThat(a).isEqualTo(arrayData); assertThat(a).isNotEqualTo(c); assertThat(a).isNotEqualTo(d); assertThat(a).isNotEqualTo(new Object()); a.close(); b.close(); c.close(); d.close(); }