Class CLocaleBuilder


  • public final class CLocaleBuilder
    extends Object
    The builder is used to build instances of CLocale from values configured by the setters.
    A CLocale object created by a builder is well-formed and can be transformed to a well-formed IETF BCP 47 language and it's also cached.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • create

        public static CLocaleBuilder create​(Language language)
        Creates a builder by the Language passed as argument.
        Parameters:
        language - language for locale building
        Returns:
        a locale builder instance
      • setScript

        public CLocaleBuilder setScript​(Script script)
        Sets the script code of the locale.
        Parameters:
        script - the script code of the locale
        Returns:
        a locale builder instance
      • setRegion

        public CLocaleBuilder setRegion​(Region region)
        Sets the region to use for locale.
        Parameters:
        region - the region to use for locale.
        Returns:
        a locale builder instance
      • setVariantAndExtension

        public CLocaleBuilder setVariantAndExtension​(String variantAndExtension)
        Sets the variant and extension parts of the locale.
        Parameters:
        variantAndExtension - the variant and extension parts of the locale
        Returns:
        a locale builder instance
      • build

        public CLocale build()
        Returns an instance of locale created from the fields set on this builder.
        Returns:
        a locale instance.
      • build

        public static CLocale build​(String localeIdentifier)
        Returns an instance of locale created from the fields set on this builder.
        Parameters:
        localeIdentifier - locale identifier to parse to get a locale.
        Returns:
        a locale instance.
      • isValid

        public static boolean isValid​(String localeIdentifier)
        Returns an instance of locale created from the fields set on this builder.
        Parameters:
        localeIdentifier - locale identifier to parse to get a locale.
        Returns:
        a locale instance.