Custom Qualifier
Using Custom Qualifier you can create your own annotation and can use it directly at the injection point. You need to create a Annotation that is self annotated with the @Qualifier annotation
So, rather then @Qualifier("kesar") you can create following custom annotation
@Target({
ElementType.CONSTRUCTOR,
ElementType.FIELD,
ElementType.METHOD,
ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface Kesar{ }
and then you can annotate your class with this
@Component
@Primary
@Kesar
public class Mango implements IceCream { ... }
Same way you can create multiple custom Qualifier and you can annotate you class with multiple
annotation for qualifying based on the requirements.
@Target({ElementType.CONSTRUCTOR,
ElementType.FIELD,
ElementType.METHOD,
ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface Badam { }