public static boolean equals(byte[] a, ByteBuffer buf) {
    if (a == null) return buf == null;
    if (buf == null) return false;
    if (a.length != buf.remaining()) return false;

    // Thou shalt not modify the original byte buffer in what should be read only operations.
    ByteBuffer b = buf.duplicate();
    for (byte anA : a) {
      if (anA != b.get()) {
        return false;
      }
    }
    return true;
  }
Lexicographically determine the equality of two byte[], one as ByteBuffer.
@param a   left operand
@param buf right operand
@return True if equal
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java