Class PersonNameFormatter.Builder

  • Enclosing class:
    PersonNameFormatter

    public static class PersonNameFormatter.Builder
    extends java.lang.Object
    A utility class that can be used to construct a PersonNameFormatter. Use PersonNameFormatter.builder() to get a new instance.
    • Constructor Detail

      • Builder

        private Builder()
    • Method Detail

      • setLocale

        public PersonNameFormatter.Builder setLocale​(java.util.Locale locale)
        Sets the locale for the formatter to be constructed.
        Parameters:
        locale - The new formatter locale. May not be null.
        Returns:
        This builder.
      • setDisplayOrder

        public PersonNameFormatter.Builder setDisplayOrder​(PersonNameFormatter.DisplayOrder order)
        Specifies the desired display order for the formatted names. This can be either SORTING, which requests that names be formatted in a manner suitable for inclusion in a sorted list (e.g., in English, "Smith, John"), or DEFAULT, which gives the standard field order suitable for most contexts (e.g., in English, "John Smith").
        Parameters:
        order - The desired display order for formatted names.
        Returns:
        This builder.
      • setSurnameAllCaps

        public PersonNameFormatter.Builder setSurnameAllCaps​(boolean allCaps)
        Requests that the surname in the formatted result be rendered in ALL CAPS. This is often done with Japanese names to highlight which name is the surname.
        Parameters:
        allCaps - If true, the surname in the formatted result will be rendered in ALL CAPS.
        Returns:
        This builder.
      • build

        public PersonNameFormatter build()
        Returns a new PersonNameFormatter with the values that were passed to this builder. This method doesn't freeze or delete the builder; you can call build() more than once (presumably after calling the other methods to change the parameter) to create more than one PersonNameFormatter; you don't need a new Builder for each PersonNameFormatter.
        Returns:
        A new PersonNameFormatter.