Inspectopedia
 
2024.3

Convert 'object' to 'data object'

Info
New
Last modified: 03 December 2024

Reports object that can be converted to data object

data object auto-generates toString, equals and hashCode

The inspection suggests to convert object to data object in 2 cases:

  • When custom toString returns name of the class

  • When object inherits sealed class/interface

Example:

After the quick-fix is applied:

This inspection only reports if the Kotlin language level of the project or module is 1.9 or higher