code: public Endpoint withWeight(int weight) {
          ensureSingle();
          validateWeight(weight);
          if (this.weight == weight) {
              return this;
          }
          return new Endpoint(host(), ipAddr(), port, weight, hostType);
      }
docs: Returns a new host endpoint with the specified weight.
  
  @return the new endpoint with the specified weight. {@code this} if this endpoint has the same weight.
  
  @throws IllegalStateException if this endpoint is not a host but a group