Hi, do you know any way to include annotations in ...
# announcements
v
Hi, do you know any way to include annotations in
typealias
? I could be great for constrains and dtos
a
Just put the annotations on the actual type
the compiler just replaces every occurence of a
typealias
with the actual type during compilation
v
That is what I am doing at the moment, but I have to repeat those annotations every time I use the alias
Something like this may be great!
Copy code
@Pattern("""\$[A-Z]{4}[0-9]{3}^""")
typealias ProductCode = String
especially it the alias is used extensively in dtos
n
that seems to be a usecase for inline classes, but i assume oyu cannto use EAP ?
v
@Nikky thx, I think it is not release yet and It is somehow link to openJDK Valhalla project
n
in this case no, inline classes are just classes wrapped around a single simple values (string, int, double) that give you typesafety during compilation but uses the simple types at runtime
but yes 1.3 is not quite released yet