HeapChannelBuffer extends AbstractChannelBuffer { @Override public void getBytes(int index, ChannelBuffer dst, int dstIndex, int length) { if (dst instanceof HeapChannelBuffer) { getBytes(index, ((HeapChannelBuffer) dst).array, dstIndex, length); } else { dst.setBytes(dstIndex, array, index, length); } } HeapChannelBuffer(int length);  HeapChannelBuffer(byte[] array); protected  HeapChannelBuffer(byte[] array, int readerIndex, int writerIndex); @Override boolean isDirect(); @Override int capacity(); @Override boolean hasArray(); @Override byte[] array(); @Override int arrayOffset(); @Override byte getByte(int index); @Override void getBytes(int index, ChannelBuffer dst, int dstIndex, int length); @Override void getBytes(int index, byte[] dst, int dstIndex, int length); @Override void getBytes(int index, ByteBuffer dst); @Override void getBytes(int index, OutputStream out, int length); int getBytes(int index, GatheringByteChannel out, int length); @Override void setByte(int index, int value); @Override void setBytes(int index, ChannelBuffer src, int srcIndex, int length); @Override void setBytes(int index, byte[] src, int srcIndex, int length); @Override void setBytes(int index, ByteBuffer src); @Override int setBytes(int index, InputStream in, int length); int setBytes(int index, ScatteringByteChannel in, int length); @Override ChannelBuffer copy(int index, int length); @Override ChannelBufferFactory factory(); @Override ByteBuffer toByteBuffer(int index, int length);  }
@Test void testEqualsAndHashcode() { HeapChannelBuffer b1 = new HeapChannelBuffer("hello-world".getBytes()); HeapChannelBuffer b2 = new HeapChannelBuffer("hello-world".getBytes()); MatcherAssert.assertThat(b1.equals(b2), is(true)); MatcherAssert.assertThat(b1.hashCode(), is(b2.hashCode())); b1 = new HeapChannelBuffer("hello-world".getBytes()); b2 = new HeapChannelBuffer("hello-worldd".getBytes()); MatcherAssert.assertThat(b1.equals(b2), is(false)); MatcherAssert.assertThat(b1.hashCode(), not(b2.hashCode())); }