Annotation Interface Named


@Qualifier @Retention(RUNTIME) @Documented public @interface Named
Provides a unique identifier for dependencies when multiple implementations of the same type are available.

This annotation can be used in conjunction with Inject to specify which implementation should be injected when multiple candidates exist. The value represents a unique identifier for the dependency.

Example usage:

 @Inject
 @Named("mysql")
 private Repository mysqlRepository;
 
Since:
4.0.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name identifier for the annotated element.
  • Element Details

    • value

      String value
      The name identifier for the annotated element.

      If no value is specified, the default empty string will be used. When used as a qualifier, this value helps distinguish between different implementations or instances of the same type.

      Returns:
      the name that identifies this component
      Default:
      ""