mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
70 lines
1.8 KiB
Kotlin
70 lines
1.8 KiB
Kotlin
// Generated code. Do not modify.
|
|
|
|
package com.yandex.div.reference
|
|
|
|
import org.json.JSONArray
|
|
import org.json.JSONObject
|
|
|
|
class EntityWithStringEnumPropertyWithDefaultValue(
|
|
@JvmField val value: Expression<Value> = VALUE_DEFAULT_VALUE, // default value: second
|
|
) : Hashable {
|
|
|
|
private var _hash: Int? = null
|
|
|
|
override fun hash(): Int {
|
|
_hash?.let {
|
|
return it
|
|
}
|
|
val hash =
|
|
this::class.hashCode() +
|
|
value.hashCode()
|
|
_hash = hash
|
|
return hash
|
|
}
|
|
|
|
fun equals(other: EntityWithStringEnumPropertyWithDefaultValue?, resolver: ExpressionResolver, otherResolver: ExpressionResolver): Boolean {
|
|
other ?: return false
|
|
return value.evaluate(resolver) == other.value.evaluate(otherResolver)
|
|
}
|
|
|
|
fun copy(
|
|
value: Expression<Value> = this.value,
|
|
) = EntityWithStringEnumPropertyWithDefaultValue(
|
|
value = value,
|
|
)
|
|
|
|
companion object {
|
|
const val TYPE = "entity_with_string_enum_property_with_default_value"
|
|
|
|
private val VALUE_DEFAULT_VALUE = Expression.constant(Value.SECOND)
|
|
}
|
|
|
|
enum class Value(private val value: String) {
|
|
FIRST("first"),
|
|
SECOND("second"),
|
|
THIRD("third");
|
|
|
|
companion object Converter {
|
|
|
|
fun toString(obj: Value): String {
|
|
return obj.value
|
|
}
|
|
|
|
fun fromString(value: String): Value? {
|
|
return when (value) {
|
|
FIRST.value -> FIRST
|
|
SECOND.value -> SECOND
|
|
THIRD.value -> THIRD
|
|
else -> null
|
|
}
|
|
}
|
|
|
|
@JvmField
|
|
val TO_STRING = { value: Value -> toString(value) }
|
|
|
|
@JvmField
|
|
val FROM_STRING = { value: String -> fromString(value) }
|
|
}
|
|
}
|
|
}
|