/**
   * Matches a converged infrastructure against the criteria in this set of filter options.
   *
   * @param ci the converged infrastructure to test
   * @return true if the converged infrastructure matches all criteria
   */
  public boolean matches(@Nonnull ConvergedInfrastructure ci) {
    if (accountNumber != null) {
      if (!accountNumber.equals(ci.getProviderOwnerId())) {
        if (!matchesAny) {
          return false;
        }
      } else if (matchesAny) {
        return true;
      }
    }
    if (regex != null) {
      boolean matches = (ci.getName().matches(regex) || ci.getDescription().matches(regex));

      if (!matches) {
        for (Map.Entry<String, String> tag : ci.getTags().entrySet()) {
          String value = tag.getValue();

          if (value != null && value.matches(regex)) {
            matches = true;
            break;
          }
        }
      }
      if (!matches && !matchesAny) {
        return false;
      } else if (matches && matchesAny) {
        return true;
      }
    }
    if (tags != null && !tags.isEmpty()) {
      if (!CloudProvider.matchesTags(ci.getTags(), ci.getName(), ci.getDescription(), tags)) {
        if (!matchesAny) {
          return false;
        }
      } else if (matchesAny) {
        return true;
      }
    }
    return !matchesAny;
  }