Annotation Interface Reference


@Documented @Target(METHOD) public @interface Reference
A Reference annotation is placed on an abstract method that will resolve to a referenced object. The reference annotation is paired with a ReferenceId method that returns the id of the referenced object. The type of the referenced object is the return type of the method annotated with @Reference. The type and id are passed to the Locator.findById(Class, Object) method when the reference is resolved. *

The reference can be resolved either eagerly (during a linking phase or when it is modified) or lazily (when accessed).

The method must also conform to the following constraints:

  • Must not be annotated with any other arez annotation
  • Must have 0 parameters
  • Must return a value
  • Must be abstract
  • Must not throw exceptions
  • Must be accessible to the class annotated by the ArezComponent annotation.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Return the enum controlling whether there is an inverse for reference.
    Define the expected multiplicity of the inverse associated with the reference.
    Return the name of the inverse associated with the reference.
    Return the strategy for resolving reference.
    Return the name of the reference relative to the component.
  • Element Details

    • name

      @Nonnull String name
      Return the name of the reference relative to the component. The value must conform to the requirements of a java identifier. If not specified, the name will be derived by assuming the naming convention "get[Name]" or failing that the name will be the method name.
      Returns:
      the name of the reference relative to the component.
      Default:
      "<default>"
    • load

      @Nonnull LinkType load
      Return the strategy for resolving reference.
      Returns:
      the strategy for resolving reference.
      Default:
      EAGER
    • inverse

      @Nonnull Feature inverse
      Return the enum controlling whether there is an inverse for reference. Feature.ENABLE tells the annotation processor to expect an inverse and add code to maintain the inverse. Feature.DISABLE will generate no code to maintain inverse module. Feature.AUTODETECT will be treated as Feature.ENABLE if either the inverseName() or inverseMultiplicity() is specified.
      Returns:
      the enum controlling whether there is an inverse for reference
      Default:
      AUTODETECT
    • inverseName

      Return the name of the inverse associated with the reference. The value must conform to the requirements of a java identifier. If not specified, the name will be derived by camelCasing the simple name of the class on which the Reference annotation is placed and then adding an s if inverseMultiplicity() is Multiplicity.MANY.
      Returns:
      the name of the reference relative to the component.
      Default:
      "<default>"
    • inverseMultiplicity

      Define the expected multiplicity of the inverse associated with the reference.
      Returns:
      the expected multiplicity of the inverse associated with the reference.
      Default:
      MANY