What is the default target for annotation when annotating a property in Kotlin?

Annotations in Kotlin can have different targets, as described here: https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets

My question is: when a website is not explicitly defined, what is the default goal when annotating a property in a class, as in the example below?

class Test {
  @SomeAnnotation
  var someProperty: String? = null
}

Background

I am trying to use Jongo as a MongoDB client in Kotlin and have problems annotating the id field. Jongo does not correctly display the id property when it is annotated as follows:

@MongoId @MongoObjectId var id: String? = null

The above annotations are just meta annotations for Jackson. However, this seems to work when I comment on a property like this, indicating a problem using the site:

@field:[MongoId MongoObjectId]
var id: String? = null

, @field -, , .

+2
1

reference :

, @Target . , :

  • param ( )
  • property ( Java)
  • field

, @Target({ElementType.FIELD}), Kotlin @field:.

@Target, : @property: .

+5

Source: https://habr.com/ru/post/1650156/


All Articles