private void searchList(
      List<DbObject> toSearch,
      List<String> searchValues,
      boolean matchAll,
      boolean ignoreCase,
      boolean useRegex) {
    if (monitor != null) {
      monitor.setMonitorType(RowActionMonitor.MONITOR_PROCESS);
    }
    int total = toSearch.size();
    int current = 1;

    for (DbObject object : toSearch) {
      numSearched++;
      if (cancelSearch) return;

      if (monitor != null) {
        monitor.setCurrentObject(object.getObjectName(), current, total);
      }

      try {
        CharSequence source = null;
        if (connection.getMetadata().isTableType(object.getObjectType())) {
          ((TableIdentifier) object).setRetrieveFkSource(true);
        }

        ProcedureDefinition def = null;
        if (object instanceof ProcedureDefinition) {
          def = (ProcedureDefinition) object;
        }

        String key = getObjectKey(object);
        if (!searchedObjects.contains(key)) {
          source = object.getSource(connection);
          if (StringUtil.isBlank(source)) {
            LogMgr.logWarning(
                "ObjectSourceSearcher.searchObjects()",
                "Empty source returned for " + object.toString());
          }

          if (StringUtil.containsWords(source, searchValues, matchAll, ignoreCase, useRegex)) {
            searchResult.add(object);
          }
          searchedObjects.add(key);
        }
      } catch (SQLException sql) {
        LogMgr.logError(
            "ObjectSourceSearcher.searchObjects()", "Error retrieving object source", sql);
      }
      current++;
    }
  }
  @Test
  public void testDomainRetrieval() throws Exception {
    WbConnection con = PostgresTestUtil.getPostgresConnection();
    if (con == null) {
      System.out.println("No PostgreSQL connection available. Skipping test...");
      return;
    }
    Collection<String> types = con.getMetadata().getObjectTypes();
    assertTrue(types.contains("DOMAIN"));
    List<TableIdentifier> objects =
        con.getMetadata().getObjectList(TEST_SCHEMA, new String[] {"DOMAIN"});
    assertEquals(2, objects.size());
    DbObject salary = objects.get(0);
    DbObject zz_int = objects.get(1);

    objects = con.getMetadata().getObjectList("other", new String[] {"DOMAIN"});
    assertEquals(1, objects.size());

    objects = con.getMetadata().getObjectList("%", new String[] {"DOMAIN"});
    assertEquals(objects.toString(), 3, objects.size());

    PostgresDomainReader reader = new PostgresDomainReader();

    List<DomainIdentifier> domains = reader.getDomainList(con, "%", "%");
    assertEquals(3, domains.size());

    assertEquals("DOMAIN", salary.getObjectType());
    assertTrue(domains.get(0) instanceof DomainIdentifier);

    String sql = salary.getSource(con).toString().trim();
    String expected =
        "CREATE DOMAIN "
            + TEST_SCHEMA.toLowerCase()
            + ".salary AS numeric(12,2)\n"
            + "   CONSTRAINT NOT NULL CHECK (VALUE > 0::numeric);";
    assertEquals(expected, sql);

    sql = zz_int.getSource(con).toString().trim();
    expected =
        "CREATE DOMAIN "
            + TEST_SCHEMA.toLowerCase()
            + ".zz_int AS integer\n"
            + "   CONSTRAINT NOT NULL;";
    assertEquals(expected, sql);

    GenericObjectDropper dropper = new GenericObjectDropper();
    dropper.setCascade(true);
    dropper.setObjects(domains);
    dropper.setConnection(con);

    String drop = dropper.getScript().toString().trim();
    //    System.out.println(drop);
    assertTrue(drop.contains("DROP DOMAIN IF EXISTS " + TEST_SCHEMA + ".zz_int"));
    assertTrue(drop.contains("DROP DOMAIN IF EXISTS " + TEST_SCHEMA + ".salary"));
    assertTrue(drop.contains("DROP DOMAIN IF EXISTS other.positive_int"));

    DataStore details = reader.getObjectDetails(con, salary);
    assertNotNull(details);
    assertEquals(1, details.getRowCount());
    assertEquals("salary", details.getValueAsString(0, 0));
    assertEquals("numeric(12,2)", details.getValueAsString(0, 1));
  }