Thank you @mernst!
I got this to work:
void startSomethingElse(@AccountIdParam long accountId, @BalanceParam long balance) {
System.out.println("Account " + accountId + " balance " + balance);
}
void startOfSomething() {
/*
* either use:
* @AccountIdParam long accountId = (@AccountIdParam long) 1;
* or
* @SuppressWarnings("assignment")
*/
@SuppressWarnings("assignment")
long accountId = 1;
@SuppressWarnings("assignment")
long balance = 100;
startSomethingElse(balance, accountId);
}
And now I have these qualifiers:
@SubtypeOf({ParamUnknown.class})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface AccountIdParam {}
@SubtypeOf({ParamUnknown.class})
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface BalanceParam {}
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@SubtypeOf({AccountIdParam.class, BalanceParam.class})
public @interface ParamBottom {}
@DefaultQualifierInHierarchy
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@SubtypeOf({})
public @interface ParamUnknown {}
If my number of qualifiers grows, this line on ParamBottom where I list them will become cumbersome. Any advice on that?