class IdGenerator {

  public static BigInteger generateNamespaceId(
      final String namespaceName, final BigInteger parentId) {
    if (!namespaceName.matches("^[a-z0-9][a-z0-9-_]*$")) {
      throw new IllegalIdentifierException("invalid namespace name");
    }

    final ByteBuffer parentIdBuffer =
        ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(parentId.longValue());
    final byte[] hash =
        IdGenerator.getHashInLittleEndian(parentIdBuffer.array(), namespaceName.getBytes());
    // Set the high bit for namespace id
    return ConvertUtils.toUnsignedBigInteger(ByteBuffer.wrap(hash).getLong() | ID_GENERATOR_FLAG);
  }

  private  IdGenerator();

}