`TYPE_USE` vs `TYPE` vs `TYPE_PARAMETER` annotations

23 Views Asked by At

I am trying to understand what would be correct usage of the annotations mentioned in the title.

I am aware of TYPE annotation usage as specified from answer here and java docs.

However after reading the article and going through the mail chain here I still have some grey areas as to what would be right usage of TYPE_USE annotation.

The grey areas for me are as follows.

  1. As mentioned in the previous stack overflow question is it a shorter form as mentioned in the 2nd answer.

  2. Does it only allow use case like below to have better type safety?

 class PersonDto {
 
   private List<@Valid Address> addresses;


  // Some other code...
}

  1. How is the code referred in 2nd point different from type check perspective to below code.
 class PersonDto {
 
  @Valid
  private List<Address> addresses;


  // Some other code...
 }

  1. As per mail chain mentioned above and my experiment with JDK-17 the example given in mail-chain it seems to be compiling fine. Proving my assumption in point 1.
0

There are 0 best solutions below