code: public void setUserAgent(String userAgent) {
          this.userAgent = userAgent.toLowerCase();
  
          // Re-order the set
          Set<UserAgentDirectives> replace = new TreeSet<UserAgentDirectives>(
              new UserAgentDirectives.UserAgentComparator(this.userAgent));
          replace.addAll(rules);
          rules = replace;
      }
docs: Change the user agent string used to crawl after initialization. This will
  reorder (recreate) the list of user agent directives for this host.
  
  @param userAgent The new user agent to use.