ByteArrayHttpData implements HttpData { @Override public boolean equals(Object obj) { if (!(obj instanceof HttpData)) { return false; } if (obj == this) { return true; } final HttpData that = (HttpData) obj; if (length() != that.length()) { return false; } return Arrays.equals(array, that.array()); } ByteArrayHttpData(byte[] array); private  ByteArrayHttpData(byte[] array, boolean endOfStream); @Override byte[] array(); @Override int length(); @Override String toString(Charset charset); @Override String toString(); @Override InputStream toInputStream(); @Override boolean isEndOfStream(); @Override ByteArrayHttpData withEndOfStream(boolean endOfStream); @Override boolean isPooled(); @Override ByteBuf byteBuf(ByteBufAccessMode mode); @Override ByteBuf byteBuf(int offset, int length, ByteBufAccessMode mode); @Override void close(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test void equals() { final HttpData a = new ByteArrayHttpData(new byte[] { 1, 2, 3, 4 }); final HttpData b = new ByteArrayHttpData(new byte[] { 1, 2, 3, 4 }); final HttpData c = new ByteArrayHttpData(new byte[] { 1, 2, 3 }); final HttpData d = new ByteArrayHttpData(new byte[] { 4, 5, 6, 7 }); final HttpData bufData = new ByteBufHttpData(Unpooled.directBuffer().writeInt(0x01020304), true); assertThat(a).isEqualTo(a); assertThat(a).isEqualTo(b); assertThat(a).isEqualTo(bufData); assertThat(a).isNotEqualTo(c); assertThat(a).isNotEqualTo(d); assertThat(a).isNotEqualTo(new Object()); bufData.close(); }