我在 Kotlin 中有这样的结构
companion object Constants {
/**
* Collection of fields and values relative to phone books.
*/
object PhoneBooks {
/**
* Field indicating the ID of a phone book.
* Each phone book must have an unique ID.
*/
const val PB_ID_KEY = "PB_ID"
/**
* Field indicating the status of phone book.
*/
const val PB_STATUS_KEY = "PB_Status"
/**
* One of the possible [PB_STATUS_KEY] values, when the phone book is in indexing state
* (usually at startup or in update phase).
*/
const val PB_INDEXING = "Indexing"
[...]
问题是我必须有可能从 Java 访问子对象中的常量值,但这似乎是不可能的。我怎样才能在不改变结构的情况下解决这个问题?