def setTargetCallbacks()

in protocol/src/main/scala/org/apache/toree/comm/CommStorage.scala [44:114]


  def setTargetCallbacks(targetName: String, commCallbacks: CommCallbacks) =
    callbackStorage(targetName) = commCallbacks

  /**
   * Removes the Comm callbacks from the specified target.
   *
   * @param targetName The name of the target whose callbacks to remove
   *
   * @return Some CommCallbacks if removed, otherwise None
   */
  def removeTargetCallbacks(targetName: String) =
    callbackStorage.remove(targetName)

  /**
   * Retrieves the current Comm callbacks for the specified target.
   *
   * @param targetName The name of the target whose callbacks to get
   *
   * @return Some CommCallbacks if found, otherwise None
   */
  def getTargetCallbacks(targetName: String): Option[CommCallbacks] =
    callbackStorage.get(targetName)

  /**
   * Determines if the specified target has any callbacks.
   *
   * @param targetName The name of the target
   *
   * @return True if a CommCallbacks instance is found, otherwise false
   */
  def hasTargetCallbacks(targetName: String) =
    callbackStorage.contains(targetName)

  /**
   * Sets the Comm ids associated with the specified target.
   *
   * @param targetName The name of the target whose Comm ids to set
   * @param links The sequence of Comm ids to attach to the target
   */
  def setTargetCommIds(
    targetName: String, links: immutable.IndexedSeq[v5.UUID]
  ) = linkStorage(targetName) = links

  /**
   * Removes the Comm ids associated with the specified target.
   *
   * @param targetName The name of the target whose Comm ids to remove
   *
   * @return Some sequence of Comm ids if removed, otherwise None
   */
  def removeTargetCommIds(targetName: String) = linkStorage.remove(targetName)

  /**
   * Removes the specified Comm id from the first target with a match.
   *
   * @param commId The Comm id to remove
   *
   * @return Some name of target linked to Comm id if removed, otherwise None
   */
  def removeCommIdFromTarget(commId: v5.UUID): Option[v5.UUID] = {
    val targetName = getTargetFromCommId(commId)

    targetName match {
      case Some(name) =>
        val commIds = getCommIdsFromTarget(name).get.filterNot(_ == commId)
        setTargetCommIds(name, commIds)
        Some(name)
      case None       =>
        None
    }
  }