Annotation Interface Name


Specifies the parameter name for bean property mapping.

This annotation is used to explicitly specify a parameter name when bytecode parameter names are not available (i.e., when code is not compiled with the -parameters flag). It allows constructors to map parameters to bean properties by name.

Can be used in the following locations:

  • On constructor and method arguments when the parameter names are not in the compiled bytecode.
Examples:

// Without -parameters flag, parameter names would be arg0, arg1, etc. public class Person { public Person(@Name("firstName") String arg0, @Name("lastName") String arg1) { // Parameters can be mapped to bean properties "firstName" and "lastName" } }

Comparison with @Named:

Do not confuse this annotation with @Named, which serves a different purpose:

  • @Name - Specifies the parameter name for bean property mapping
  • @Named - Specifies which named bean to inject (bean qualifier)
Example showing the difference:

// @Name - for parameter naming public Person(@Name("firstName") String arg0) { // Maps parameter to bean property "firstName" } // @Named - for bean injection public MyService(@Named("primaryDb") Database db) { // Injects the bean named "primaryDb" from BeanStore }

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The bean property or parameter name.
  • Element Details

    • value

      The bean property or parameter name.
      Returns:
      The annotation value.