class ConditionRouter implements Router, Comparable<Router> {

  public Map<String, ServiceProvider> route(Map<String, ServiceProvider> providers, URL url)
          throws RpcException {
    if (providers == null || providers.size() == 0) {
      return providers;
    }
    try {
      if (!matchWhen(url)) {
        return providers;
      }
      Map<String, ServiceProvider> result = new ConcurrentHashMap<String, ServiceProvider>();
      if (thenCondition == null) {
        logger.log(Level.FINE, "The current consumer in the service blacklist. consumer: " + NetUtils.getLocalHost() + ", service: " + url.getServiceKey());
        return result;
      }
      for (Map.Entry<String, ServiceProvider> entry : providers.entrySet()) {
        if (matchThen(entry.getValue().getUrl(), url)) {
          result.put(entry.getKey(), entry.getValue());
        }
      }
      if (result.size() > 0) {
        return result;
      } else if (force) {
        logger.log(Level.FINE, "The route result is empty and force execute. consumer: " + NetUtils.getLocalHost()
                + ", service: " + url.getServiceKey() + ", router: " + url.getParameterAndDecoded(Constants.RULE_KEY));
        return result;
      }
    } catch (Throwable t) {
      logger.log(Level.SEVERE, "Failed to execute condition router rule: " + getUrl() + ", invokers: " + providers + ", cause: " + t.getMessage(), t);
    }
    return providers;
  }

  public  ConditionRouter(URL url);

}