Am I being stupid just now, or is the only way of ...
# announcements
l
Am I being stupid just now, or is the only way of properly annotating a constructor-defined property like this:
Copy code
class CreateUserDTO(
        @Email @get:Email @setparam:Email
        var email: String
)
? I mean, isnt't there a way to combine these things? When I annotate the constructor param, I usually also want to annotate the getter and setter, right?
y
if you want the annotation to be present on all the elements, then yes, you need to copy it, but is this really the common case?
🆗 1
q
U wanna something like this
@[get setparam]:Email
looks terrible 🙂
😅 1
l
I'd argue that at least constructor +
setparam
is a really common combination. But I agree that all three (or even four, with
field
) of them are really rare. The main issue is though, that it's not intuitive that the "normal" annotation will not be transfered to the getter. It makes complete sense, but it's not intuitive
@qwert_ukg I thought of
@accessors:
or something
q
I agree with @yole its not a common case (actually, as targeting with multiply annotations
@set:[Email Name]
, but it is implemented 🙂 )
l
Maybe it's just because java, but I noticed that the whole use-site-target thing is confusing to many (especially for beginners). Even though I know about it, I often have to think twice.
by the way a good example where it's really common are the android support annotations. e.g.
@StringRes
or
@Dimension
.