Enum Language

java.lang.Object
java.lang.Enum<Language>
io.github.zazalng.contracts.Language
All Implemented Interfaces:
Serializable, Comparable<Language>

@Deprecated public enum Language extends Enum<Language>
Deprecated.
Enumeration of supported output languages for currency text conversion.

This enum defines the available languages that can be used when converting numeric amounts to textual representations in the Thai Baht library. Each language has specific formatting rules, unit words, and a default negative prefix that is automatically applied when using the configuration builder.

Supported Languages

  • THAI: Converts amounts to Thai text with Thai grammar rules. Unit words: "บาท" (Baht), "สตางค์" (Satang), "ถ้วน" (Only/Exact). Default negative prefix: "ลบ" (Thai minus)
  • ENGLISH: Converts amounts to English with standard English conventions. Unit words: "Baht", "Satang", "Only". Default negative prefix: "Minus"

Language-Specific Rules

Each language has specialized conversion handlers:

  • Thai: Implements Thai numerical grammar including:
    • "เอ็ด" for ones in larger numbers (e.g., 101 = "หนึ่งร้อยเอ็ด")
    • "ยี่" for tens/twenties (e.g., 20 = "ยี่สิบ")
    • Repeating "ล้าน" for millions and beyond
    • Silent "หนึ่ง" in certain positions
  • English: Implements standard English conventions including:
    • Hyphenated compound numbers (e.g., "Twenty-Five")
    • Standard position words: "Hundred", "Thousand", "Million"
    • Regular singular/plural handling

Negative Prefix Behavior (v1.3.0+)

Each language has a default negative prefix that is applied when configuring for negative amounts:

  • THAI: Default prefix "ลบ" (Thai minus)
  • ENGLISH: Default prefix "Minus"
When switching languages via ThaiBahtConfig.Builder.language(Language), the prefix automatically updates to the new language's default UNLESS it has been explicitly set via ThaiBahtConfig.Builder.setPrefix(String). Once you set a custom prefix, it is preserved even when changing languages. To reset to language defaults, create a new builder.

Usage Examples

Example 1 - Thai language (default):


 ThaiBahtConfig config = ThaiBahtConfig.builder()
     .language(Language.THAI)
     .build();
 String result = ThaiBaht.of(new BigDecimal("1234.56"), config);
 // Output: "หนึ่งพันสองร้อยสามสิบสี่บาทห้าสิบหกสตางค์"
 

Example 2 - English language:


 ThaiBahtConfig config = ThaiBahtConfig.builder(Language.ENGLISH)
     .build();
 String result = ThaiBaht.of(new BigDecimal("1234.56"), config);
 // Output: "One Thousand Two Hundred Thirty-Four Baht Fifty-Six Satang"
 

Example 3 - Language switching with prefix preservation:


 // Thai with custom prefix
 ThaiBahtConfig thai = ThaiBahtConfig.builder()
     .setPrefix("ติดลบ")  // Explicitly set
     .build();

 // Switch to English - custom prefix is preserved
 ThaiBahtConfig english = thai.toBuilder()
     .language(Language.ENGLISH)
     .build();
 // Prefix remains "ติดลบ" instead of updating to "Minus"
 

Example 4 - Negative amounts:


 String thai = ThaiBaht.of(new BigDecimal("-500"),
     ThaiBahtConfig.builder(Language.THAI).build());
 // Output: "ลบห้าร้อยบาทถ้วน"

 String english = ThaiBaht.of(new BigDecimal("-500"),
     ThaiBahtConfig.builder(Language.ENGLISH).build());
 // Output: "Minus Five Hundred Baht Only"
 
Since:
1.3.0
Author:
Zazalng
See Also:
  • Enum Constant Details

    • THAI

      public static final Language THAI
      Deprecated.
      Thai language output.

      Converts amounts to Thai text representation using traditional Thai numerical conventions. Includes special handling for Thai grammar rules such as "เอ็ด" (ones in compounds), "ยี่" (tens), and repeating "ล้าน" (millions).

      Unit words:

      • "บาท" (Baht) - Main currency unit
      • "สตางค์" (Satang) - Fractional currency unit
      • "ถ้วน" (Only/Exact) - Indicator when satang is zero

      Default negative prefix: "ลบ" (Thai minus)

      Example output:

      • 1234.56 → "หนึ่งพันสองร้อยสามสิบสี่บาทห้าสิบหกสตางค์"
      • 100.00 → "หนึ่งร้อยบาทถ้วน"
      • -50.00 → "ลบห้าสิบบาทถ้วน"
    • ENGLISH

      public static final Language ENGLISH
      Deprecated.
      English language output.

      Converts amounts to English text representation using standard English conventions. Includes proper formatting with hyphens for compound numbers and standard position names.

      Unit words:

      • "Baht" - Main currency unit
      • "Satang" - Fractional currency unit
      • "Only" - Indicator when satang is zero (also called "Exact")

      Default negative prefix: "Minus"

      Example output:

      • 1234.56 → "One Thousand Two Hundred Thirty-Four Baht Fifty-Six Satang"
      • 100.00 → "One Hundred Baht Only"
      • -50.00 → "Minus Fifty Baht Only"
  • Method Details

    • values

      public static Language[] values()
      Deprecated.
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Language valueOf(String name)
      Deprecated.
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getUnit

      public String getUnit()
      Deprecated.
      Returns the currency unit word for this language.

      The main currency unit represents the baht (integer part).

      Returns:
      the currency unit word ("บาท" for THAI, "Baht" for ENGLISH), never null
    • getExact

      public String getExact()
      Deprecated.
      Returns the exact/only indicator word for this language.

      This word is displayed when the amount has no fractional satang (i.e., satang = 0).

      Returns:
      the exact indicator ("ถ้วน" for THAI, "Only" for ENGLISH), never null
    • getSatang

      public String getSatang()
      Deprecated.
      Returns the satang (fractional) unit word for this language.

      The satang unit represents the fractional part of the currency.

      Returns:
      the satang unit word ("สตางค์" for THAI, "Satang" for ENGLISH), never null
    • getPrefix

      public String getPrefix()
      Deprecated.
      Returns the default negative prefix for this language.

      This prefix is automatically used for negative amounts unless explicitly overridden via ThaiBahtConfig.Builder.setPrefix(String).

      Returns:
      the negative prefix ("ลบ" for THAI, "Minus" for ENGLISH), never null