class ByteBufferReference extends AbstractBytesReference {

    private final ByteBuffer buffer;
    private final int length;

    ByteBufferReference(ByteBuffer buffer) {
        this.buffer = buffer.slice();
        this.length = buffer.remaining();
    }

    @Override
    public byte get(int index) {
        return buffer.get(index);
    }

    @Override
    public int getInt(int index) {
        return buffer.getInt(index);
    }

    @Override
    public int length() {
        return length;
    }

    @Override
    public BytesReference slice(int from, int length) {<FILL_FUNCTION_BODY>}

    /**
     * This will return a bytes ref composed of the bytes. If this is a direct byte buffer, the bytes will
     * have to be copied.
     *
     * @return the bytes ref
     */
    @Override
    public BytesRef toBytesRef() {
        if (buffer.hasArray()) {
            return new BytesRef(buffer.array(), buffer.arrayOffset(), length);
        }
        final byte[] copy = new byte[length];
        buffer.get(copy, 0, length);
        return new BytesRef(copy);
    }

    @Override
    public long ramBytesUsed() {
        return buffer.capacity();
    }
}

        Objects.checkFromIndexSize(from, length, this.length);
        buffer.position(from);
        buffer.limit(from + length);
        ByteBufferReference newByteBuffer = new ByteBufferReference(buffer);
        buffer.position(0);
        buffer.limit(this.length);
        return newByteBuffer;
    
<methods>public non-sealed void <init>() ,public int compareTo(org.elasticsearch.common.bytes.BytesReference) ,public boolean equals(java.lang.Object) ,public int getInt(int) ,public int hashCode() ,public int indexOf(byte, int) ,public BytesRefIterator iterator() ,public org.elasticsearch.common.io.stream.StreamInput streamInput() throws java.io.IOException,public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder, org.elasticsearch.common.xcontent.ToXContent.Params) throws java.io.IOException,public java.lang.String utf8ToString() ,public void writeTo(java.io.OutputStream) throws java.io.IOException<variables>private java.lang.Integer hash