2

I have the following parameters in a companion object on Kotlin

    companion object Constants {
    /**
     * Values for the various type of connection that a device can have.
     */
    const val CONNECTION_KEY = "Connection_type"
    const val CONNECTION_AUX = "AUX"
    const val CONNECTION_BLUETOOTH = "Bluetooth"
    const val CONNECTION_USB = "USB"

    /**
     * Unique IDs respectively for devices and media elements.
     */
    const val DEVICE_ID_KEY = "Device_ID"
    const val MEDIA_ID_KEY = "Media_ID"

    /**
     * Various keys that you can find in [Bundle] returned by [getMediaItems].
     */
    const val MEDIA_NAME_KEY = "Media_name"
    const val SONG_IDS_KEY = "Songs_ids"
    const val GENRE_IDS_KEY = "Genres_ids"
    const val ARTIST_IDS_KEY = "Artists_ids"
}

The problem is that, in Kdoc results, I find them in alphabetical order

ARTIST_IDS_KEY

const val ARTIST_IDS_KEY: String

CONNECTION_AUX

const val CONNECTION_AUX: String

CONNECTION_BLUETOOTH

const val CONNECTION_BLUETOOTH: String

CONNECTION_KEY

Values for the various type of connection that a device can have.

const val CONNECTION_KEY: String

CONNECTION_USB

const val CONNECTION_USB: String

DEVICE_ID_KEY

Unique IDs respectively for devices and media elements.

const val DEVICE_ID_KEY: String

GENRE_IDS_KEY

const val GENRE_IDS_KEY: String

MEDIA_ID_KEY

const val MEDIA_ID_KEY: String

MEDIA_NAME_KEY

Various keys that you can find in Bundle returned by getMediaItems.

const val MEDIA_NAME_KEY: String

SONG_IDS_KEY

const val SONG_IDS_KEY: String

... is there a way to mantain original order?

Lore
  • 1,286
  • 1
  • 22
  • 57

1 Answers1

2

You can group elements in kDoc by grouping them in the code:

companion object Constants {
    /**
     * Values for the various type of connection that a device can have.
     */
    object Connection {
        const val KEY = "Connection_type"
        const val AUX = "AUX"
        const val BLUETOOTH = "Bluetooth"
        const val USB = "USB"
    }

    /**
     * Unique IDs respectively for devices and media elements.
     */
    object IDs {
        const val DEVICE = "Device_ID"
        const val MEDIA = "Media_ID"
    }

    /**
     * Various keys that you can find in [Bundle] returned by [getMediaItems].
     */
    object BundleKeys {
        const val MEDIA_NAME = "Media_name"
        const val SONG_IDS = "Songs_ids"
        const val GENRE_IDS = "Genres_ids"
        const val ARTIST_IDS = "Artists_ids"   
    }
}
IlyaMuravjov
  • 2,352
  • 1
  • 9
  • 27
  • thank you, you where very useful. Do you know how can I access these objects from Java? – Lore Nov 22 '19 at 09:34
  • 1
    @Lore You can either `import packagename.OuterClass.Constants;` and use `Constants.Connection.KEY`, remove `companion` modifier and use `OuterClass.Constants.Connection.KEY` or move these nested objects out of companion object to `OuterClass` and use `OuterClass.Connection.KEY`. – IlyaMuravjov Nov 22 '19 at 17:05