Annotation Interface PluralOf


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface PluralOf
Describes the string that constitutes the plural of this element or attribute name. Can also be used to supply the exact method name for the adder, remover and locator methods for this element. This annotation will ONLY be read from the method that also has an XmlElement annotation on it

The rules for determining the singular form of the element name is the following:

  1. Remove the get or set from the method name. The remainder is the element name
  2. decapitalize the element name
  3. If the element name has more than one letter and ends in "s", remove the "s"
  4. The remainder is the singular of the element name
  5. For example, if the method name is getDoctors, the singular element name will be "doctor". In that case the adder method will be addDoctor, the remover method will be removeDoctor and the lookup method will be lookupDoctor. In some cases the singular of a word is the same as the plural. If that word does not end in s the default behavior works fine. For example if the method name is getMoose, the singular element name will be "moose". The adder method will be addMoose and so on.

    In cases that do not conform to the above rule this annotation is provided, which allows the user to specify what this element name is the plural of. For example, if the method name is getMice then this annotation should be used: VPluralOf("mouse") In this case the adder method will become addMouse, the remover will be removeMouse and the lookup will be lookupMouse.

    This annotation can also be used to specify the exact method name that should be used for the adder, remover and lookup. If those fields are filled in the will override the algorithm for determining the singular for this element name.

Author:
jwells
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns the exact name of the method that should be used as the adder for this element
    Returns the exact name of the method that should be used as the lookkup for this element
    Returns the exact name of the method that should be used as the remover for this element
    Returns the singular of the element name described by this setter or getter method.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    This value is used to indicate that the normal algorithm should be used for determining the singular of the element name
  • Field Details

    • USE_NORMAL_PLURAL_PATTERN

      static final String USE_NORMAL_PLURAL_PATTERN
      This value is used to indicate that the normal algorithm should be used for determining the singular of the element name
      See Also:
  • Element Details

    • value

      String value
      Returns the singular of the element name described by this setter or getter method. This name should be fully capitalized as it should appear after the "add", "remove" or "lookup" in the method name.

      For example, if this is returning the singular for "mice", it should return "Mouse".

      Returns:
      The singular of the element name, or USE_NORMAL_PLURAL_PATTERN if the normal algorithm should be applied
      Default:
      "*"
    • add

      String add
      Returns the exact name of the method that should be used as the adder for this element
      Returns:
      The exact name of the method that should be used as the adder for this element, or USE_NORMAL_PLURAL_PATTERN if the normal algorithm should be used (as modified by the value() method)
      Default:
      "*"
    • remove

      String remove
      Returns the exact name of the method that should be used as the remover for this element
      Returns:
      The exact name of the method that should be used as the remover for this element, or USE_NORMAL_PLURAL_PATTERN if the normal algorithm should be used (as modified by the value() method)
      Default:
      "*"
    • lookup

      String lookup
      Returns the exact name of the method that should be used as the lookkup for this element
      Returns:
      The exact name of the method that should be used as the lookup for this element, or USE_NORMAL_PLURAL_PATTERN if the normal algorithm should be used (as modified by the value() method)
      Default:
      "*"