Annotation Type ConstructorArg


@Retention(RUNTIME)
@Target(PARAMETER)
public @interface ConstructorArg
Annotation for the auto injection of immutable beans. As with Java up to version 8 is not possible to retrieve the constructor's parameter name through reflection, this annotation needs to be specified next to each one of them. e.g. public class Square { private final int x; private final int y; public Square(@ConstructorArg("x") final int x, @ConstructorArg("y") final int y) { this.x = x; this.y = y; } }
  • Required Element Summary

    Required Elements
    Modifier and Type Required Element Description
    java.lang.String value
    The field name in the target object.
  • Element Details

    • value

      java.lang.String value
      The field name in the target object. It's needed because the field name cannot be retrieved through reflection in the constructor.
      Returns:
      the field name