@Override
  public void visitConfig(ClientConfig config) {
    if (!"client".equals(config.getMode())) {
      throw new RuntimeException(String.format("Attribute(%s) is required: %s", "mode", config));
    } else if (config.getServers().size() == 0) {
      config.setEnabled(false);
      log("WARN", "CAT client was disabled due to no CAT servers configured!");
    } else if (!config.isEnabled()) {
      log("WARN", "CAT client was globally disabled!");
    }

    m_config = config;
    super.visitConfig(config);

    if (m_config.isEnabled()) {
      for (Domain domain : m_config.getDomains().values()) {
        if (!domain.isEnabled()) {
          m_config.setEnabled(false);
          log("WARN", "CAT client was disabled in domain(" + domain.getId() + ") explicitly!");
        }

        break; // for first domain only
      }
    }
  }
  @Override
  public void visitServer(Server server) {
    super.visitServer(server);

    // set default values
    if (server.getPort() == null) {
      server.setPort(2280);
    }

    if (server.getEnabled() == null) {
      server.setEnabled(true);
    }
  }
  @Override
  public void visitDomain(Domain domain) {
    super.visitDomain(domain);

    // set default values
    if (domain.getEnabled() == null) {
      domain.setEnabled(true);
    }

    if (domain.getIp() == null) {
      domain.setIp(getLocalAddress());
    }
  }