Files
divkit/api_generator/tests/references/shared_data_kotlin/EntityWithStringEnumPropertyWithDefaultValue.kt
gulevsky c9caf87860 add code generation of json serializers
commit_hash:3ad603b95c6c6ead4feaa591da3fbe2e91751455
2024-09-25 12:55:58 +03:00

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) }
}
}
}