Is there an easy way to interop between Kotlin `da...
# announcements
n
Is there an easy way to interop between Kotlin `data class`es and more traditional libs that require Bean/POJO annotations? If I’m using a lib that requires annotations on a POJO/bean as well as normal getters/setters, I’d like to use a
data class
but I don’t think I can apply annotations to those fields.
m
annotations on
data
class properties in general can work -- this is from the Android Room documentation:
Copy code
@Entity
data class User(
    @PrimaryKey var id: Int,
    var firstName: String?,
    var lastName: String?
)
so, try
@get:YourAnnotation
or
@field:YourAnnotation
and see if it works
n
Oh neat! I also just found https://www.kotlin.nl/2018/02/06/kotlin-quick-tip-annotation-targets/ which says similar things. Thanks Mark!
👍 2