private def has[T]()

in kernel/src/main/scala/org/apache/toree/boot/CommandLineOptions.scala [130:189]


  private def has[T](spec: OptionSpec[T]): Boolean =
    options.has(spec)

  private def get[T](spec: OptionSpec[T]): Option[T] =
    Some(options.valueOf(spec)).filter(_ != null)

  private def getAll[T](spec: OptionSpec[T]): Option[List[T]] =
    Some(options.valuesOf(spec).asScala.toList).filter(_ != null)

  /*
   * Expose options in terms of their existence/value.
   */

  val help: Boolean = has(_help)

  val version: Boolean = has(_version)

  /*
   * Config object has 3 levels and fallback in this order
   * 1. Comandline Args
   * 2. --profile file
   * 3. Defaults
   */
  def toConfig: Config = {
    val profileConfig: Config = get(_profile) match {
      case Some(x) =>
        ConfigFactory.parseFile(x)
      case None =>
        ConfigFactory.empty()
    }

    val commandLineConfig: Config = ConfigFactory.parseMap(Map(
      "stdin_port" -> get(_stdin_port),
      "shell_port" -> get(_shell_port),
      "iopub_port" -> get(_iopub_port),
      "control_port" -> get(_control_port),
      "hb_port" -> get(_heartbeat_port),
      "ip" -> get(_ip),
      "interpreter_args" -> interpreterArgs,
      "magic_urls" -> getAll(_magic_url).map(_.asJava)
        .flatMap(list => if (list.isEmpty) None else Some(list)),
      "max_interpreter_threads" -> get(_max_interpreter_threads),
      "alternate_sigint" -> get(_alternate_sigint),
      "jar_dir" -> get(_jar_dir),
      "default_interpreter" -> get(_default_interpreter),
      // deprecated in favor of spark-context-initialization-mode none
      // "nosparkcontext" -> (if (has(_nosparkcontext)) Some(true) else Some(false)),
      "spark_context_initialization_mode" -> (if( has(_spark_context_initialization_mode)) get(_spark_context_initialization_mode)
        else ( if (has(_nosparkcontext)) Some("none") else Some("lazy"))),
      "spark_context_initialization_timeout" -> get(_spark_context_initialization_timeout),
      "interpreter_plugins" -> interpreterPlugins,
      "default_repositories" -> getAll(_default_repositories).map(_.asJava)
        .flatMap(list => if (list.isEmpty) None else Some(list)),
      "default_repository_credentials" -> getAll(_default_repository_credentials).map(_.asJava)
          .flatMap(list => if (list.isEmpty) None else Some(list))

    ).flatMap(removeEmptyOptions).asInstanceOf[Map[String, AnyRef]].asJava)

    commandLineConfig.withFallback(profileConfig).withFallback(ConfigFactory.load)
  }