Annotation Type Messages.Select


  • @Retention(RUNTIME)
    @Target(PARAMETER)
    public static @interface Messages.Select
    Provides multiple forms based on a dynamic parameter. This annotation is applied to a single parameter of a Messages subinterface and indicates that parameter is to be used to choose the proper form of the message. The parameter chosen must be of type Enum, String, boolean, or a primitive integral type. This is frequently used to get proper gender for translations to languages where surrounding words depend on the gender of a person or noun. This also marks the parameter as Messages.Optional.

    Example:

       @DefaultMessage("{0} likes their widgets.")
       @AlternateMessage({
           "FEMALE", "{0} likes her widgets.",
           "MALE", "{0} likes his widgets.",
       })
       String example(String name, @Select Gender gender)