commonMain.com.seiko.imageloader.model.ExtraData.kt Maven / Gradle / Ivy
package com.seiko.imageloader.model
typealias ExtraData = Map
typealias ExtraDataBuilder = MutableMap
val EmptyExtraData get() = emptyMap()
private const val KEY_MIME_TYPE = "KEY_MIME_TYPE"
private const val KEY_META_DATA = "KEY_META_DATA"
fun extraData(block: ExtraDataBuilder.() -> Unit) = buildMap(block)
fun ExtraDataBuilder.mimeType(type: String?) {
if (!type.isNullOrEmpty()) set(KEY_MIME_TYPE, type)
}
val ExtraData.mimeType: String?
get() = get(KEY_MIME_TYPE) as? String
internal fun ExtraDataBuilder.metadata(metadata: Any?) {
if (metadata != null) set(KEY_META_DATA, metadata)
}
internal inline val ExtraData.metadata: Any?
get() = get(KEY_META_DATA)