io.hackle.sdk.common.Event.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hackle-sdk-common Show documentation
Show all versions of hackle-sdk-common Show documentation
Hackle SDK for Java and Kotlin
package io.hackle.sdk.common
/**
* @author Yong
*/
data class Event internal constructor(
val key: String,
val value: Double?,
val properties: Map
) {
class Builder(private val key: String) {
private var value: Double? = null
private val properties = PropertiesBuilder()
fun value(value: Double) = apply { this.value = value }
fun property(key: String, value: Any?) = apply { this.properties.add(key, value) }
fun properties(properties: Map?) = apply { properties?.let { this.properties.add(it) } }
fun build() = Event(key, value, properties.build())
}
companion object {
@JvmStatic
fun of(key: String) = Event(key, null, emptyMap())
@JvmStatic
fun builder(key: String) = Builder(key)
}
}