All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.algolia.client.configuration.internal.AlgoliaAgent.kt Maven / Gradle / Ivy

Go to download

"Algolia is a powerful search-as-a-service solution, made easy to use with API clients, UI libraries, and pre-built integrations. Algolia API Client for Kotlin lets you easily use the Algolia Search REST API from your JVM project, such as Android or backend implementations."

There is a newer version: 3.10.1
Show newest version
package com.algolia.client.configuration.internal

import com.algolia.client.configuration.AgentSegment

/** Handles to handle algolia agent segments. */
internal class AlgoliaAgent(clientVersion: String) {

  private val segments =
    mutableSetOf(
      AgentSegment("Algolia for Kotlin", clientVersion),
    )

  fun add(segment: AgentSegment): Boolean {
    return segments.add(segment)
  }

  fun add(segments: List): Boolean {
    return this.segments.addAll(segments)
  }

  fun remove(segment: AgentSegment): Boolean {
    return segments.remove(segment)
  }

  override fun toString(): String {
    return segments.joinToString("; ") { it.formatted() }
  }

  private fun AgentSegment.formatted(): String = buildString {
    append(value)
    version?.let { version ->
      append(" (")
      append(version)
      append(")")
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy