Annotation Type MessagesFor

    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      Class<?> type
      Returns the type that should be treated as the source type, i.e.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean forProperties
      Returns whether message keys for all bean properties of the annotated type should be created.
      boolean forType
      Returns whether a message key for the annotated type should be created.
      String[] ignoreImplicitKeys
      Returns a list of message keys that should be ignored for message key creation, like specfic bean properties or enum elements.
      String[] keys
      (Additional) Message keys.
      String prefix
      The prefix to be used for message keys.
      String targetPackage
      Returns the target package in which to generate code for the source type.
      String[] value
      (Additional) Message keys.
    • Field Detail

      • TARGET_PACKAGE_DEFAULT

        static final String TARGET_PACKAGE_DEFAULT
    • Element Detail

      • type

        Class<?> type
        Returns the type that should be treated as the source type, i.e. if it were annotated with Messages directly.
        Returns:
        the type that should be treated as the source type, i.e. if it were annotated with Messages directly
      • targetPackage

        String targetPackage
        Returns the target package in which to generate code for the source type.

        It's in the nature of @MessagesFor to generate code (like the message key constants) for types in other projects/modules/artifacts. So generating the code in the same package as the source type would create split packages (several artifacts providing classes to the same package). With the Java Platform Module System split packages aren't allowed anymore and will result in compiler errors. That's why a mapping must either be specified here (which will take precedence) or globally in the messages configuration.

        Returns:
        the target package in which to generate code for the source type
        Default:
        "__DEFAULT__"
      • forType

        boolean forType
        Returns whether a message key for the annotated type should be created. Only relevant when the annotation is directly on the type.
        Returns:
        whether a message key for the annotated type should be created
        Default:
        false
      • forProperties

        boolean forProperties
        Returns whether message keys for all bean properties of the annotated type should be created. Only relevant on classes.
        Returns:
        whether message keys for all bean properties of the annotated type should be created
        Default:
        false
      • ignoreImplicitKeys

        String[] ignoreImplicitKeys
        Returns a list of message keys that should be ignored for message key creation, like specfic bean properties or enum elements.
        Returns:
        whether the annotated element should be ignored for the implicit generation of message keys
        Default:
        {}
      • prefix

        String prefix
        The prefix to be used for message keys. This can only be set if this annotation is at the type level. If not set, the fully qualified name of the source type is used.
        Returns:
        prefix to be used for message keys
        Default:
        "__SOURCE_TYPE__"
      • value

        String[] value
        (Additional) Message keys. The provided strings will be used as local parts in the message keys. This is an alias for keys().
        Returns:
        message keys
        Default:
        {}
      • keys

        String[] keys
        (Additional) Message keys. The provided strings will be used as local parts in the message keys. This is an alias for value().
        Returns:
        message keys
        Default:
        {}