В котлине это класс значений, например
Код: Выделить всё
@JvmInline
value class CountryId(private val id: UUID) {
override fun toString(): String = id.toString()
companion object { fun empty(): CountryId = CountryId(EMPTY_UUID) }
}
Код: Выделить всё
class IdentifierFactory
{
companion object {
fun buildString(): String {
return "hello"
}
fun buildCountry(): CountryId {
return CountryId.empty()
}
}
}
Неужели в Java так плохо с классами Value?
ps. Я также пытался использовать @JvmStatic, но безуспешно
pps. Если я декомпилирую байт-код Kotlin со стороны Java и получу CountryId.decompiled.java, вот как будет выглядеть конструктор
Код: Выделить всё
// $FF: synthetic method
private CountryId(UUID id) {
Intrinsics.checkNotNullParameter(id, "id");
super();
this.id = id;
}
Подробнее здесь: https://stackoverflow.com/questions/699 ... es-in-java
Мобильная версия