Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 446 Vote(s) - 3.64 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to apply a single annotation to multiple use-site targets in Kotlin?

#1
According to the documentation:

[To see links please register here]


You can apply multiple annotations to a single site-use target, but is there a way to apply the same annotation to multiple site-use targets?

My use-case is decorating classes with annotations for SimpleXML. To use an immutable `data class`, you have to annotate **both** the field and the constructor parameter:

```data class Data(
@field:Element(name = "ID")
@param:Element(name = "ID")
val id: Int,
@param:Element(name = "TEXT")
@field:Element(name = "TEXT")
val text: String)
```

For data classes with many fields, you can easily end up with 3x as many annotations as actual code, and it would be nice to eliminate the duplication. This is especially annoying when you have to use a complicated annotation like `ElementUnion` which can be multiple lines on its own.
Reply

#2
Unfortunately, as of Kotlin 1.3, there's no syntax for this use case
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through