class SearchServerInteractor extends ObservableInteractor<Server, SearchServerInteractor.Params> {

  @Override
  protected Observable<Server> buildReactiveStream(Params params) {
    if (params == null) {
      return Observable.error(new IllegalArgumentException("Params must be provided"));
    }

    NetworkAddress networkAddress = params.networkAddress;
    if (networkAddress != null && !networkAddressValidator.isValid(networkAddress)) {
      return Observable.error(new IllegalArgumentException("Invalid IP Address"));
    }

    return networkAddress != null ? searchServerService.searchServer(networkAddress)
        : searchServerService.searchServer();
  }

  public  SearchServerInteractor(SearchServerService searchServerService,
      NotifyServerFoundService notifyServerFoundService,
      Validator<NetworkAddress> networkAddressValidator, ThreadExecutor threadExecutor,
      PostExecutionThread postExecutionThread);

}