-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageUrl.kt
43 lines (38 loc) · 1.21 KB
/
ImageUrl.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) SRG SSR. All rights reserved.
* License information is available from the LICENSE file.
*/
@file:Suppress("MemberVisibilityCanBePrivate")
package ch.srg.dataProvider.integrationlayer.data
import ch.srg.dataProvider.integrationlayer.data.serializer.ImageUrlSerializer
import java.io.Serializable
/**
* Image url
*
* @property rawUrl Internal image url, to retrieve the url use [ImageUrl.decorated].
*/
@Suppress("SerialVersionUIDInSerializableClass")
@kotlinx.serialization.Serializable(with = ImageUrlSerializer::class)
data class ImageUrl(
/**
* Only for internal use! Please use a Decorator!
*
* @return the undecorated url
*/
val rawUrl: String
) : Serializable {
/**
* Decorated
*
* @param decorator The [ImageUrlDecorator] used to decorate the [rawUrl].
* @param widthPixels The width of the image.
* @return The decorated [rawUrl].
*/
fun decorated(decorator: ImageUrlDecorator, widthPixels: Int): String {
return decorator.decorate(rawUrl, widthPixels)
}
@Deprecated("Using toString is not recommended in this case.", replaceWith = ReplaceWith("rawUrl"))
override fun toString(): String {
return rawUrl
}
}