private List<TableDescriptor> getTableDescriptors(final List<TableDescriptor> htds,
    final String namespace, final String regex, final List<TableName> tableNameList,
    final boolean includeSysTables) throws IOException {
    if (tableNameList == null || tableNameList.isEmpty()) {
      // request for all TableDescriptors
      Collection<TableDescriptor> allHtds;
      if (namespace != null && namespace.length() > 0) {
        // Do a check on the namespace existence. Will fail if does not exist.
        this.clusterSchemaService.getNamespace(namespace);
        allHtds = tableDescriptors.getByNamespace(namespace).values();
      } else {
        allHtds = tableDescriptors.getAll().values();
      }
      for (TableDescriptor desc : allHtds) {
        if (
          tableStateManager.isTablePresent(desc.getTableName())
            && (includeSysTables || !desc.getTableName().isSystemTable())
        ) {
          htds.add(desc);
        }
      }
    } else {
      for (TableName s : tableNameList) {
        if (tableStateManager.isTablePresent(s)) {
          TableDescriptor desc = tableDescriptors.get(s);
          if (desc != null) {
            htds.add(desc);
          }
        }
      }
    }

    // Retains only those matched by regular expression.
    if (regex != null) filterTablesByRegex(htds, Pattern.compile(regex));
    return htds;
  }
Return a list of table table descriptors after applying any provided filter parameters. Note
that the user-facing description of this filter logic is presented on the class-level javadoc
of {@link NormalizeTableFilterParams}.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java